/*
------------- Create by Agung Novian -----------------------
------------- http://www.agungnovian.com -------------------
------------- http://www.i-bego.com ------------------------
------------- E-Mail: pujanggabageur@yahoo.com -------------
------------- Please don't delete this comment -------------
------------- For non commercial use only ------------------
------------- For commercial use please contact owner ------
*/

(function($){
	$.loadTheme = function(obj, param){
		param = $.extend({
			theme: 'blue'
		}, param);
		
		var id = $(obj).attr("id");
		var bodyContent = $('body').html();
		var urlStyle =  'themes/' + param.theme + '/style.css';
		var urlCore =  'themes/' + param.theme + '/core.html';
		
		var htmlStyle = $.ajax({
			url: urlStyle,
			async: false
		}).responseText; 
		
		htmlStyle = htmlStyle.replace(/%color%/g, param.theme)
		var strStyle ="\r\n<style type='text/css'>\r\n" + htmlStyle + "\r\n</style>\r\n";
		
		var addObject = "<input type='hidden' id='txtFrmSelected' />";
		
		$('body').html("");
		$('body').prepend(strStyle);
		$('body').append(bodyContent);
		$('body').append(addObject);
		
		//Load Core
		var htmlCore = $.ajax({
			url: urlCore,
			async: false
		}).responseText;
		
		var strCore ="\r\n\t" + htmlCore + "\t\r\n";
		$("#" + id).html(strCore);
		
	}
	
	$.createRibbon = function(obj, param){
		var selTab = 0;
		var blnMinimized = 0;
		var blnShowPopup = 0;
		var selItem = '';
		var blnShowFile = 0;
		var blnLock = 0;
		var blnLockFile = 0;
		var arrScroll = new Array();
		var selForm="";
		
		param = $.extend({
			theme: 'black',
			tabIndex: '0',
			icon: '',
			extForm: 'php',
			prefixForm: '',
			onClick: false,
			onChange: false,
			onKeypress: false,
			onKeyup: false,
			onKeydown: false,
			onReady: false
		}, param);
		
		var ribbon = {
			divide: function(numerator, denominator){
				var remainder = numerator % denominator;
				var quotient = (numerator - remainder) / denominator;
				if (quotient >= 0)
					quotient = Math.floor(quotient);
				else
					quotient = Math.ceil(quotient); 
				return quotient;
			},
			createRibbonTab: function(parent, id, caption){
				strContent = "";
				strContent = "\r\n<td>\r\n<table class='ribbonTab' id='" + id + "'>\r\n";
				strContent += "<tr>\r\n";
				strContent += "\t<td class='ribbonTab-left-tab' id='ribbonTab-left-tab-" + id + "'>";
				strContent += "\t</td>";
				strContent += "\t<td class='ribbonTab-center-tab' id='ribbonTab-center-tab-" + id + "'>";
				strContent += caption;
				strContent += "\t</td>";
				strContent += "\t<td class='ribbonTab-right-tab' id='ribbonTab-right-tab-" + id + "'>";
				strContent += "\t</td>";
				strContent += "</tr>\r\n";
				strContent += "\r\n</table>\r\n</td>";
				$("#"+parent).append(strContent);
			},
			createRibbonPage: function(parent, side, id, caption){
				strContent = "";
				strContent = "\r\n<tr class='ribbonPage' id='ribbonPage-" + side + "-" + id + "'>\r\n";
				strContent += "\r\n<td>\r\n<table>\r\n";
				strContent += "<tr class='ribbonGroupContainer' id='ribbonGroupContainer-" + side + "-" + id + "'>\r\n";
				strContent += "</tr>\r\n";
				strContent += "\r\n</table>\r\n</td>\r\n";
				strContent += "\r\n</tr>\r\n";
				$("#"+parent).append(strContent);
			},
			createRibbonGroup: function(parent, side, id, caption, ribbonOption){
				strContent = "";
				strContent += "\r\n<td>\r\n<table class='ribbonGroup' id='ribbonGroup-" + side + "-" + id + "'>\r\n";
				strContent += "<tr>\r\n";
				strContent += "\t<td>";
				strContent += "\t<ul class='GroupItemContainer' id='GroupitemContainer-" + side + "-" + id + "'>";
				strContent += "\t</ul>";
				strContent += "\t</td>\r\n";
				strContent += "</tr>\r\n";
				strContent += "<tr>\r\n";
				strContent += "\t<td class='ribbonGroupCaption'>\r\n";
				strContent += caption;
				strContent += "\t</td>\r\n";
				
				if (ribbonOption){
					optionID = ribbonOption[0].id;
					optionName = ribbonOption[0].name;
					strContent += "<td style='width:4px;'>" ;
					strContent += "<div class='optionButton' ";
					strContent += " id='" + optionID + "'";
					strContent += " itemID='" +  side + "-" + optionID + "'";
					strContent += " itemName='" + optionName + "'";
					strContent += "><img style='margin:-1px;float:left;' src='themes/";
					strContent += param.theme + "/images/corner.png' /></div></td>";
				}
				
				strContent += "</tr>\r\n";
				strContent += "\r\n</table>\r\n</td>";
				
				$("#"+parent).append(strContent);
			},
			createItemsContainer: function(parent, side, id){
				strContent = "<li class='itemContainer' id='itemContainer-" + side + "-" + id + "'>";
				strContent += "</li>";
				
				$("#"+parent).append(strContent);
			},
			createSmallItemsContainer: function(parent, side, ids){	
				var arrID = new Array();
				arrID = ids.split(";");
				var lenID = arrID.length;
				
				strContent = "<ul class='smallItemContainer'>";
				
				for (var li= 0; li < (lenID-1); li++){
					newID = arrID[li];
					if (newID != ''){
						strContent += "<li style='float:none;' id='itemContainer-" + side + "-" + newID + "'>";
						strContent += "</li>";
					}
				}
				strContent += "</ul>";
				
				$("#"+parent).append(strContent);
			},
			createPanel: function(id, name, position, width){
			
				if (position ==undefined) position = 'left';
				if (position =='undefined') position = 'left';
				if (position =='') position = 'left';
				
				if (width ==undefined) width = 0;
				if (width =='undefined') width = 0;
				if (width =='') width = 0;
				
				strContent = "<li style='float:"+position+";list-style:none;'>";
				strContent += "<ul itemName='" + name;
				if (width == 0){
					strContent += "' ";
				} else {
					strContent += "' style='width:" + width + "px'" ;
				}
				
				strContent += " class='panelContent' id='panelContent-"+id+"'>";
				strContent += "</ul></li>";
				
				$(".statusbar").append(strContent);
			},
			createToolTip: function(id, type, width, image, title, content){
				
				if (width == undefined) width = 'default';
				if (width == 'undefined') width = 'default';
				if (width == '') width = 'default';
				
				if (image == undefined) image = '';
				if (image == 'undefined') image = '';
				if (image == '') image = '';
				
				if (type == undefined) image = '0';
				if (type == 'undefined') image = '0';
				if (type == '') image = '0';
				
				strContent = "";
				
				strContent += "<div class='tooltip' ";
				strContent += " 'id=tooltip-" + id + "' ";
				strContent += ">";
				strContent += "<div id='tooltip-title'>";
				strContent += title;
				strContent += "</div>";
				strContent += "<div id ='tooltip-content'>";
				if (image != ''){
					strContent += "<table>";
					strContent += "<tr>";
					strContent += "<td>";
					strContent += "<img src='images/" + image + "'>";
					strContent += "</td>";
					strContent += "<td>";
					strContent += content;
					strContent += "</td>";
					strContent += "</tr>";
					strContent += "</table>";
				} else {
					strContent += "<table>";
					strContent += "<tr>";
					strContent += "<td>";
					strContent += content;
					strContent += "</td>";
					strContent += "</tr>";
					strContent += "</table>";
				}
				strContent += "</div>"
				strContent += "</div>";
				
				$("body").append(strContent);
			},
			createItem: function(parent, id, type, size, width, name, image, caption, checked, enabled, grouped, form, action, list){
				if (size == undefined) size = 'small';
				if (size == 'undefined') size = 'small';
				if (size == '') size = 'small';
				
				if (width == undefined) width = 'default';
				if (width == 'undefined') width = 'default';
				if (width == '') width = 'default';
				
					blnCaption = 0;
					newCaption = "";
					
					if (caption != undefined){
						if (caption != 'undefined'){
							if (caption != ''){
								blnCaption = 1;
							}
						}
					}
					
					if (list!=undefined){
						if (list!='undefined'){
							if (list!=''){
								list = list;
							} else {
								list = "";
							}
						} else {
							list = "";
						}
					} else {
						list = "";
					}
					
					if (list != "" ){
						strContent = "\t<" + list + "><table class='ribbonItem'";
					} else {
						strContent = "\t<table class='ribbonItem'";
					}
					
				switch(size){
				case "large":
					if (blnCaption==1){
						arrCaption = new Array();
						arrCaption = caption.split(" ");
						lenCaption = arrCaption.length;
						
						if (lenCaption > 0){
							for (var li= 0; li < lenCaption; li++){
								newCaption += arrCaption[li];
								if (li < lenCaption-1) {
									newCaption += '<br/>';
								}
							}
						}
						
						if ((type=='buttonpopup')||(type=='buttonsplitpopup')){
							if (lenCaption == 1 ){
								newCaption += "<div><img style='' src='themes/" + param.theme + "/images/dn.png' /></div>";
							} else if (lenCaption > 1 ) {
								newCaption += "<span>&nbsp;<img style='' src='themes/" + param.theme + "/images/dn.png' /></span>";
							}
						} else {
							if (lenCaption == 1){
								newCaption += '<br/>&nbsp';
							}
						}
					}
					
					strContent += " id='" + id + "'";
					strContent += " itemName='" + name + "'";
					strContent += " itemType='" + type + "'";
					strContent += " itemSize='" + size + "'";
					strContent += " itemChecked='" + checked + "'";
					strContent += " itemEnabled='" + enabled + "'";
					strContent += " itemGrouped='" + grouped + "'";
					strContent += " itemForm='" + form + "'";
					strContent += " itemAction='" + action + "'";
					strContent += ">\r\n";
					strContent += "<tr>\r\n";
					strContent += "<td class='itemImage' itemID='" + id + "' id='itemImage-" + id + "'>\r\n";
					strContent += "<img class='imgItem' itemEnabled='" + enabled + "' src='images/" + image + "' \>\r\n";
					strContent += "</td>\r\n";
					strContent += "</tr>\r\n";
					
					if (blnCaption==1){
						strContent += "<tr>\r\n";
						if (enabled==0){
							strContent += "<td class='itemCaption' style='height:27px;color:rgb(100,100,100)' itemID='" + 
							id + "' id='itemCaption-" + id + "'>\r\n";
						} else {
							strContent += "<td class='itemCaption' style='height:27px' itemID='" + id + 
							"' id='itemCaption-" + id + "'>\r\n";
						}
						strContent += newCaption + "\r\n";
						strContent += "</td>\r\n";
						strContent += "</tr>\r\n";
					}
					
					strContent += "\t</table>\r\n";
					
					if (list != "" ) strContent += "\t<" + list + ">"; 
					
					$("#"+parent).append(strContent);
					
					if (checked==1) ribbon.largeItemChecked($("#"+id));
					
				break;
				case "medium":
					if (type=='button'){
						strContent += " id='" + id + "'";
						strContent += " itemName='" + name + "'";
						strContent += " itemType='" + type + "'";
						strContent += " itemSize='" + size + "'";
						strContent += " itemChecked='" + checked + "'";
						strContent += " itemEnabled='" + enabled + "'";
						strContent += " itemForm='" + form + "'";
						strContent += " itemAction='" + action + "'";
						strContent += ">\r\n";
						strContent += "<tr>\r\n";
						strContent += "<td class='itemImage' itemID='" + id + "' id='itemImage-" + id + "' >\r\n";
						strContent += "<img class='imgItem' itemEnabled='" + enabled + "' src='images/" + image + "' \>\r\n";
						strContent += "</td>\r\n";
						strContent += "</tr>\r\n";
						
						if (blnCaption==1){
							strContent += "<tr>\r\n";
							if (enabled==0){
								strContent += "<td class='itemCaption' style='height:12px;' itemID='" + 
								id + "' id='itemCaption-" + id + "'>\r\n";
							} else {
								strContent += "<td class='itemCaption' style='height:12px' itemID='" + id + 
								"' id='itemCaption-" + id + "'>\r\n";
							}
							strContent += caption + "\r\n";
							strContent += "</td>\r\n";
							strContent += "</tr>\r\n";
						}
					
					} else if (type='|'){
						strContent += ">\r\n";
						strContent += "</tr>\r\n<td class='toolbar-sparator'><div></div></td></tr>\r\n";
					}
					strContent += "\t</table>\r\n";
					if (list != "" ) strContent += "\t<" + list + ">"; 
					
					$("#"+parent).append(strContent);
				break;
				case "small":
					switch (type){
					case "label":
						strContent += " id='" + id + "'";
						strContent += " itemName='" + name + "'";
						strContent += " itemType='" + type + "'";
						strContent += " itemSize='" + size + "'";
						strContent += " itemEnabled='" + enabled + "'";
						strContent += " itemGrouped='" + grouped + "'";
						strContent += " style='height:21px;'";
						strContent += ">\r\n";
						strContent += "<tr>\r\n";
						
						if (enabled==0){
							strContent += "<td class='itemCaption' style='border-top:0px;color:rgb(100,100,100);' itemID='" + 
							id + "' id='itemCaption-" + id + "'>\r\n";
						} else {
							strContent += "<td class='itemCaption' style='border-top:0px' itemID='" + id + 
							"' id='itemCaption-" + id + "'>\r\n";
						}
						strContent += "<label>" + caption + "</label>\r\n";
						strContent += "</td>\r\n";
						
						strContent += "</tr>\r\n";
						strContent += "\t</table>\r\n";
						
						if (list != "" ) strContent += "\t<" + list + ">"; 
						
						$("#"+parent).append(strContent);
					break;
					case "text":
						strContent += " itemType='" + type + "'";
						strContent += " itemSize='" + size + "'";
						strContent += " itemEnabled='" + enabled + "'";
						strContent += " itemGrouped='" + grouped + "'";
						strContent += " style='padding:0' >\r\n";
						strContent += "<tr>\r\n";
						
						if (enabled==0){
							strContent += "<td class='itemCaption' style='border-top:0px;color:rgb(100,100,100);padding:0' itemID='" + 
							id + "' id='itemCaption-" + id + "'>\r\n";
						} else {
							strContent += "<td class='itemCaption' style='border-top:0px;padding:0' itemID='" + id + 
							"' id='itemCaption-" + id + "'>\r\n";
						}
						strContent += "<label for='" + name + "'>" + caption + "&nbsp";
						strContent += "<input type='text' class='ribbonInput' ";
						strContent += " id='ribbonInput-" + id + "'";
						strContent += " itemName='" + name + "'";
						
						if (width != 'default') strContent += " style='width:" + width + "px;' ";
						if (enabled==0) strContent += " disabled";
						strContent += " />";
						strContent += "</label>\r\n";
						strContent += "</td>\r\n";
						
						strContent += "</tr>\r\n";
						strContent += "\t</table>\r\n";
						
						if (list != "" ) strContent += "\t<" + list + ">"; 
						
						$("#"+parent).append(strContent);
					break;
					case "spin":
						strContent += " itemID='" + id + "'";
						strContent += " itemType='" + type + "'";
						strContent += " itemSize='" + size + "'";
						strContent += " itemEnabled='" + enabled + "'";
						strContent += " itemGrouped='" + grouped + "'";
						strContent += " style='padding:0' >\r\n";
						strContent += "<tr>\r\n";
						
						if (enabled==0){
							strContent += "<td class='itemCaption' style='border-top:0px;color:rgb(100,100,100);padding:0' itemID='" + 
							id + "' id='itemCaption-" + id + "'>\r\n";
						} else {
							strContent += "<td class='itemCaption' style='border-top:0px;padding:0' itemID='" + id + 
							"' id='itemCaption-" + id + "'>\r\n";
						}
						
						strContent += "<table>";
						strContent += "<tr>";
						strContent += "<td rowspan='2'>";
						strContent += "<label for='" + name + "'>" + caption + "&nbsp";
						strContent += "<input type='text' class='ribbonInputSpin' ";
						strContent += " id='ribbonInputSpin-" + id + "'";
						strContent += " itemName='" + name + "'";
						if (width != 'default') strContent += " style='width:" + width + "px;' ";
						if (enabled==0) strContent += " disabled";
						strContent += " itemName='" + name + "' />";
						strContent += "</label>\r\n";
						strContent += "</td>\r\n";
						strContent += "<td class='ribbonButonSpinUp' itemID='" + id + "'>\r\n";
						strContent += "";
						strContent += "</td>\r\n";
						strContent += "</tr>\r\n";
						strContent += "<tr>\r\n";
						strContent += "<td class='ribbonButonSpinDn' itemID='" + id + "'>\r\n";
						strContent += "";
						strContent += "</td>\r\n";
						strContent += "</tr>\r\n";
						strContent += "</table>";
						
						strContent += "</td>\r\n";
						
						strContent += "</tr>\r\n";
						strContent += "\t</table>\r\n";
						
						if (list != "" ) strContent += "\t<" + list + ">"; 
						
						$("#"+parent).append(strContent);
					break;
					case "check":
						if ((checked=='undefined')|| (checked==undefined)) checked = 0;
						
						strContent += " id='" + id + "'";
						strContent += " itemID='" + id + "'";
						strContent += " itemName='" + name + "'";
						strContent += " itemType='" + type + "'";
						strContent += " itemSize='" + size + "'";
						strContent += " itemChecked='" + checked + "'";
						strContent += " itemEnabled='" + enabled + "'";
						strContent += " itemGrouped='" + grouped + "'";
						strContent += " itemForm='" + form + "'";
						strContent += " itemAction='" + action + "'";
						strContent += " style='height:21px;'";
						strContent += ">\r\n";
						strContent += "<tr>\r\n";
						strContent += "<td class='itemImage' " + " itemName='" + name + "'" + "itemID='" + id + "' id='itemImage-" + id + "' " ;
						strContent += " style='width:9px;background:url(themes/" + param.theme + "/images/checkbox.png) 0px 4px no-repeat'";
						if (checked==1){
							strContent += "0 0'";
						} else {
							strContent += "0 0'";
						}
						strContent += ">\r\n";
						strContent += "</td>\r\n";
						
						if (caption != undefined){
							if (caption != 'undefined'){
								if (caption != ''){
									if (enabled==0){
										strContent += "<td class='itemCaption' style='border-top:0px;color:rgb(100,100,100);padding-left:5px;' itemID='" + 
										id + "' id='itemCaption-" + id + "'>\r\n";
									} else {
										strContent += "<td class='itemCaption' style='border-top:0px;padding-left:5px;' itemID='" + id + 
										"' id='itemCaption-" + id + "'>\r\n";
									}
									strContent += caption + "\r\n";
									strContent += "</td>\r\n";
								}
							}
						}
						strContent += "<td class='itemDropdown' itemID='" + id + "' id='itemDropdown-" + id + "'></td>"; 
						strContent += "</tr>\r\n";
						strContent += "\t</table>\r\n";
						
						if (list != "" ) strContent += "\t<" + list + ">"; 
						
						$("#"+parent).append(strContent);
						
						if (enabled==0) {
							if (checked == 0){
								$('#itemImage-'+id).css({
									'background': 'url("themes/' + param.theme + '/images/checkbox.png") -52px 4px no-repeat'
								});
							} else if (itemChecked == 1){
								$('#itemImage-'+id).css({
									'background': 'url("themes/' + param.theme + '/images/checkbox.png") -65px 4px no-repeat'
								});
							}	
						} else {
							if (itemChecked == 1){
								$("#itemImage-"+id).css({'background': 'url("themes/' + param.theme + '/images/checkbox.png") -26px 4px no-repeat'}); 
							} else if (itemChecked == 0){
								$('#itemImage-'+id).css({
									'background': 'url("themes/' + param.theme + '/images/checkbox.png") 0px 4px no-repeat'
								});
							}	
						}
					break;
					case "combo":
						if (list != "" ){
							strContent = "\t<" + list + "><table class='ribbonItem' style='border:0;padding:0'";
						} else {
							strContent = "\t<table class='ribbonItem' style='border:0;padding:0'";
						}
						strContent += " id='" + id + "'";
						strContent += " itemID='" + id + "' ";
						strContent += " itemType='" + type + "'";
						strContent += " itemSize='" + size + "'";
						strContent += " itemEnabled='" + enabled + "'";
						strContent += " itemGrouped='" + grouped + "'";
						strContent += " style='padding:0' >\r\n";
						strContent += "<tr>\r\n";
						
						if (enabled==0){
							strContent += "<td class='itemCaption' style='border-top:0px;color:rgb(100,100,100);padding:0' itemID='" + 
							id + "' id='itemCaption-" + id + "'>\r\n";
						} else {
							strContent += "<td class='itemCaption' style='border-top:0px;padding:0' itemID='" + id + 
							"' id='itemCaption-" + id + "'>\r\n";
						}
						strContent += "<label for='" + name + "'>" + caption + "&nbsp";
						strContent += "<input type='text' class='ribbonCombo' ";
						strContent += " id='ribbonCombo-" + id + "'";
						strContent += " itemName='" + name + "' ";
						strContent += " itemID='" + id + "' ";
						if (width != 'default') strContent += " style='width:" + width + "px;' ";
						if (enabled==0) strContent += " disabled";
						strContent += " />";
						strContent += "</label>\r\n";
						strContent += "</td>\r\n";
						
						strContent += "<td class='comboDropdown' id='comboDropdown-" + id + 
						"' itemID='" + id + "'></td>";
						
						strContent += "</tr>\r\n";
						strContent += "\t</table>\r\n";
						
						if (list != "" ) strContent += "\t<" + list + ">"; 
						
						$("#"+parent).append(strContent);
					break;
					default:
						if (list != "" ){
							strContent = "\t<" + list + "><table class='ribbonItem'";
						} else {
							strContent = "\t<table class='ribbonItem'";
						}
						strContent += " id='" + id + "'";
						strContent += " itemName='" + name + "'";
						strContent += " itemType='" + type + "'";
						strContent += " itemSize='" + size + "'";
						strContent += " itemChecked='" + checked + "'";
						strContent += " itemEnabled='" + enabled + "'";
						strContent += " itemGrouped='" + grouped + "'";
						strContent += " itemForm='" + form + "'";
						strContent += " itemAction='" + action + "'";
						strContent += ">\r\n";
						strContent += "<tr>\r\n";
						
						if (image != "") {
							strContent += "<td class='itemImage' itemID='" + id + "' id='itemImage-" + id + "'>\r\n";
							strContent += "<img class='imgItem' itemEnabled='" + enabled + 
							"' src='images/" + image + "' style='width:16px;height:16px'\>\r\n";
						}
						
						strContent += "</td>\r\n";
						
						if (caption != undefined){
							if (caption != 'undefined'){
								if (caption != ''){
									if (enabled==0){
										strContent += "<td class='itemCaption' style='border-top:0px;color:rgb(100,100,100);' itemID='" + 
										id + "' id='itemCaption-" + id + "'>\r\n";
									} else {
										strContent += "<td class='itemCaption' style='border-top:0px;height:20px;' itemID='" + id + 
										"' id='itemCaption-" + id + "'>\r\n";
									}
									strContent += caption + "\r\n";
									strContent += "</td>\r\n";
								}
							}
						}
						
						if ((type=='buttonpopup')||(type=='buttonsplitpopup')){
							strContent += "<td class='itemDropdown' itemID='" + id + "' id='itemDropdown-" + id + 
							"'><img style='' src='themes/" + param.theme + "/images/dn.png' /></td>"; 
						} else {
							if (caption != undefined){
								if (caption != 'undefined'){
									if (caption != ''){
										strContent += "<td class='itemDropdown' itemID='" + id + "' id='itemDropdown-" + id + "'></td>"; 
									}
								}
							}
						}
						strContent += "</tr>\r\n";
						strContent += "\t</table>\r\n";
						
						if (list != "" ) strContent += "\t<" + list + ">"; 
						
						$("#"+parent).append(strContent);
						
						if (checked==1) ribbon.smallItemChecked($("#"+id)); 
					break;
					}
					
				break;
				}
				
			},
			createGalleryContainer: function(line, parent, side, id, name, caption, width, height){
				if (width == undefined){width = 200;}
				if (width == 'undefined'){width = 200;}
				if (width == ''){width = 200;}
				
				if (height == undefined){height = 50;}
				if (height == 'undefined'){height = 50;}
				if (height == ''){height = 50;}
				
				strContent = "<div class='galleryContainer' id='divGalleryContainer-"  + side +  "-"  + id + "' ";
				strContent += " style='width:" + width + "px;";
				strContent += " height:" + height + "px;";
				strContent += "'>";
				strContent += "<table style='width:100%;'";
				strContent += " id='galleryContainer-" + side + "-" + id + "' ";
				strContent += " galleryName='" + name + "' ";
				strContent += ">";
				if (caption != undefined){
					if (caption != 'undefined'){
						if (caption != ''){
							strContent += "<tr>";
							strContent += "<td style='width:100%' class='galleryTitle' colspan='100'>";
							strContent += caption;
							strContent += "</td>";
							strContent += "</tr>";
						}
					}
				}
				
				strContent += "<tr>";
				strContent += "<td>";
				strContent += "<ul class='galleryItems' id='galleryItems-" + side + "-"  + id + "' ";
				newwidth = (width);
				if (line=='hor'){
					strContent += " style='float:left;width:" + newwidth + "px' ";
				} else {
					strContent += " style='float:none;width:" + newwidth + "px' ";
				}
				strContent += "></ul>";
				strContent += "</td>";
				strContent += "<td>";
				strContent += "<table style='width:15px;height:" + height + "px;position:fixed;margin-left:-16px'>";
				strContent += "<tr><td class='gallery-scroll-top' itemID='" + side + "-"  + id + "'></td></tr>";
				strContent += "<tr><td class='gallery-scroll-bottom' itemID='" + side + "-"  + id + "'></td></tr>";
				strContent += "<tr><td class='gallery-scroll-popup' itemID='" + side + "-"  + id + "'></td></tr>";
				strContent += "</table>";
				strContent += "</td>";
				strContent += "</tr>";
				strContent += "</table>";
				strContent += "</div>";
				
				$('#'+parent).append(strContent);
			},
			createItemGallery: function(line, parent, id, type, size, name, image, caption, checked, enabled, form, action){
				if (line=='hor'){
					strContent = "<li style='float:left;list-style:none'>"
				} else {
					strContent = "<li style='float:none;list-style:none'>"
				}
				switch(size){
				case "large":
					blnCaption = 0;
					newCaption = "";
					
					if (caption != undefined){
						if (caption != 'undefined'){
							if (caption != ''){
								blnCaption = 1;
							}
						}
					}
					
					if (blnCaption==1){
						arrCaption = new Array();
						arrCaption = caption.split(" ");
						lenCaption = arrCaption.length;
						
						if (lenCaption > 0){
							for (var li= 0; li < lenCaption; li++){
								newCaption += arrCaption[li];
								if (li < lenCaption-1) {
									newCaption += '<br/>';
								}
							}
						}
						
						if ((type=='buttonpopup')||(type=='buttonsplitpopup')){
							if (lenCaption == 1 ){
								newCaption += "<div><img style='' src='themes/" + param.theme + "/images/dn.png' /></div>";
							} else if (lenCaption > 1 ) {
								newCaption += "<span>&nbsp;<img style='' src='themes/" + param.theme + "/images/dn.png' /></span>";
							}
						} else {
							if (lenCaption == 1){
								newCaption += '<br/>&nbsp';
							}
						}
					}
				
					strContent += "\t<table style='width:100%;' class='ribbonItem'";
					strContent += " id='" + id + "'";
					strContent += " itemName='" + name + "'";
					strContent += " itemType='" + type + "'";
					strContent += " itemSize='" + size + "'";
					strContent += " itemChecked='" + checked + "'";
					strContent += " itemEnabled='" + enabled + "'";
					strContent += " itemForm='" + form + "'";
					strContent += " itemAction='" + action + "'";
					strContent += ">\r\n";
					strContent += "<tr>\r\n";
					strContent += "<td class='itemImage' itemID='" + id + "' id='itemImage-" + id + "'>\r\n";
					strContent += "<img class='imgItem' itemEnabled='" + enabled + "' src='images/" + image + "' \>\r\n";
					strContent += "</td>\r\n";
					strContent += "</tr>\r\n";
					
					if (blnCaption==1){
						strContent += "<tr>\r\n";
						strContent += "<td class='itemCaption' style='height:27px' itemID='" + id + "' id='itemCaption-" + id + "'>\r\n";
						strContent += newCaption + "\r\n";
						strContent += "</td>\r\n";
					}
					
					strContent += "</tr>\r\n";
					strContent += "\t</table>\r\n";
				break;
				case "small":
					strContent += "\t<table style='width:100%' class='ribbonItem' ";
					strContent += " id='" + id + "'";
					strContent += " itemName='" + name + "'";
					strContent += " itemType='" + type + "'";
					strContent += " itemSize='" + size + "'";
					strContent += " itemChecked='" + checked + "'";
					strContent += " itemEnabled='" + enabled + "'";
					strContent += " itemForm='" + form + "'";
					strContent += " itemAction='" + action + "'";
					strContent += ">\r\n";
					strContent += "<tr>\r\n";
					strContent += "<td class='itemImage' itemID='" + id + "' id='itemImage-" + id + "' style='width:20px; border-right:1px solid rgb(200,200,200)'>\r\n";
					strContent += "<img class='imgItem' itemEnabled='" + enabled + "' style='width:16px;height:16px' src='images/" + image + "' \>\r\n";
					strContent += "</td>\r\n";
					
					if (caption != undefined){
						if (caption != 'undefined'){
							if (caption != ''){
								strContent += "<td style='text-align:left;padding-left:8px;min-width:100px' class='itemCaption' style='border-top:0px' itemID='" + id + "' id='itemCaption-" + id + "'>\r\n";
								strContent += caption + "\r\n";
								strContent += "</td>\r\n";
							}
						}
					}
					
					if ((type=='buttonpopup')||(type=='buttonsplitpopup')){
						strContent += "<td class='itemDropdown' itemID='" + id + "' id='itemDropdown-" + id + "'><img style='' src='themes/" + param.theme + "/images/dn.png' /></td>"; 
					} else {
						if (caption != undefined){
							if (caption != 'undefined'){
								if (caption != ''){
									strContent += "<td class='itemDropdown' itemID='" + id + "' id='itemDropdown-" + id + "'></td>"; 
								}
							}
						}
					}
					strContent += "</tr>\r\n";
					strContent += "\t</table>\r\n";
				break;
				}
				strContent += "</li>";
				$("#"+parent).append(strContent);
			},
			createMenuContainer: function(id){
				strContent = "<div class='menuContainer' id='menuContainer-" + id +"'>";
				strContent += "<table style='width:auto'>";
				strContent += "</table>";
				strContent += "</div>";
				$('body').append(strContent);
			},
			createItemFile: function(id, type, name, image, caption, enabled, form, action){
				if (type=='button'){
					strContent = "<li class='itemFilePage' itemType='"+type+"' id='itemFilePage-" + id + "' style='height:22px;padding:2px;width:100px;margin:auto;' itemName='" + name + "'>";
					strContent += "\t<table style='width:100%;padding:2px;' ";
					strContent += " id='" + id + "'";
					strContent += ">\r\n";
					strContent += "<tr>\r\n";
					if (image != "") {
						strContent += "<td class='itemFilePageImage' itemID='" + id + "' id='itemFilePageImage-" + id + "' style='width:20px;'>\r\n";
						strContent += "<img itemEnabled='" + enabled + "' style='width:16px;height:16px;' src='images/" + image + "' \>\r\n";
						strContent += "</td>\r\n";
					}
					if (caption != undefined){
						if (caption != 'undefined'){
							if (caption != ''){
								strContent += "<td style='text-align:left;vertical-align:middle;padding-left:8px;min-width:20px;' class='itemFilePageCaption' itemID='" + id + "' id='itemFilePageCaption-" + id + "'>\r\n";
								strContent += "<label id='itemLabel-" + id + "'>" + caption + "</label>\r\n";
								strContent += "</td>\r\n";
							}
						}
					}
					strContent += "</tr>\r\n";
					strContent += "\t</table>\r\n";
				} else if (type=='popup'){
					strContent = "<li class='itemFilePage' itemID='"+ id +"' itemType='" + type + "' id='itemFilePage-" + id + "' style='padding:12px 2px;padding-left:14px;text-align:left' itemName='" + name + "'>";
					if (caption != undefined){
						if (caption != 'undefined'){
							if (caption != ''){
								strContent += "<label>" + caption + "</label>\r\n";
							}
						}
					}
				}
				
				strContent += "</li>";
				
				$(".filePageButtons").append(strContent);
			},
			createItemMenu: function(parent, id, type, size, name, image, caption, checked, enabled, form, action){
				strContent = "<tr><td style='width:100%;'>";
				switch(size){
				case "large":
					arrCaption = new Array();
					arrCaption = caption.split(" ");
					lenCaption = arrCaption.length;
					
					newCaption = "";
					
					if (lenCaption > 0){
						for (var li= 0; li < lenCaption; li++){
							newCaption += arrCaption[li];
							if (li < lenCaption-1) {
								newCaption += '<br/>';
							}
						}
					}
					
					if ((type=='buttonpopup')||(type=='buttonsplitpopup')){
						if (lenCaption == 1 ){
							newCaption += "<div><img style='' src='themes/" + param.theme + "/images/dn.png' /></div>";
						} else if (lenCaption > 1 ) {
							newCaption += "<span>&nbsp;<img style='' src='themes/" + param.theme + "/images/dn.png' /></span>";
						}
					} else {
						if (lenCaption == 1){
							newCaption += '<br/>&nbsp';
						}
					}
					strContent += "\t<table style='width:100%;' class='ribbonItem'";
					strContent += " id='" + id + "'";
					strContent += " itemName='" + name + "'";
					strContent += " itemType='popup" + type + "'";
					strContent += " itemSize='" + size + "'";
					strContent += " itemChecked='" + checked + "'";
					strContent += " itemEnabled='" + enabled + "'";
					strContent += " itemForm='" + form + "'";
					strContent += " itemAction='" + action + "'";
					strContent += ">\r\n";
					strContent += "<tr>\r\n"; 
					if (image != "") {
						strContent += "<td class='itemImage' itemID='" + id + "' id='itemImage-" + id + "'>\r\n";
						strContent += "<img class='imgItem' itemEnabled='" + enabled + "' src='images/" + image + "' \>\r\n";
						strContent += "</td>\r\n";
					}
					strContent += "</tr>\r\n";
					strContent += "<tr>\r\n";
					strContent += "<td class='itemCaption' style='height:27px' itemID='" + id + "' id='itemCaption-" + id + "'>\r\n";
					strContent += "<label>" + newCaption + "</label>\r\n";
					strContent += "</td>\r\n";
					strContent += "</tr>\r\n";
					strContent += "\t</table>\r\n";
				break;
				case "small":
					strContent += "\t<table style='width:100%' class='ribbonItem' ";
					strContent += " id='" + id + "'";
					strContent += " itemName='" + name + "'";
					strContent += " itemType='popup" + type + "'";
					strContent += " itemSize='" + size + "'";
					strContent += " itemChecked='" + checked + "'";
					strContent += " itemEnabled='" + enabled + "'";
					strContent += " itemForm='" + form + "'";
					strContent += " itemAction='" + action + "'";
					strContent += ">\r\n";
					strContent += "<tr>\r\n";
					if (image != "") {
						strContent += "<td class='itemImage' itemID='" + id + "' id='itemImage-" + id + "' style='width:20px; border-right:1px solid rgb(200,200,200)'>\r\n";
						strContent += "<img class='imgItem' itemEnabled='" + enabled + "' style='width:16px;height:16px' src='images/" + image + "' \>\r\n";
						strContent += "</td>\r\n";
					}
					if (caption != undefined){
						if (caption != 'undefined'){
							if (caption != ''){
								strContent += "<td style='text-align:left;padding-left:8px;min-width:20px;height:20px;' class='itemCaption' style='border-top:0px' itemID='" + id + "' id='itemCaption-" + id + "'>\r\n";
								strContent += "<label id='itemLabel-" + id + "''>" + caption + "</label>\r\n";
								strContent += "</td>\r\n";
							}
						}
					}
					
					if ((type=='buttonpopup')||(type=='buttonsplitpopup')){
						strContent += "<td class='itemDropdown' itemID='" + id + "' id='itemDropdown-" + id + "'><img style='' src='themes/" + param.theme + "/images/dn.png' /></td>"; 
					} else {
						if (caption != undefined){
							if (caption != 'undefined'){
								if (caption != ''){
									strContent += "<td class='itemDropdown' itemID='" + id + "' id='itemDropdown-" + id + "'></td>"; 
								}
							}
						}
					}
					strContent += "</tr>\r\n";
					strContent += "\t</table>\r\n";
				break;
				}
				strContent += "</td></tr>";
				$("#"+parent).append(strContent);
			},
			largeItemOver: function(el){
				itemEnabled = $(el).attr("itemEnabled");
				if (itemEnabled == 'undefined'){
					itemEnabled = 1;
				}
				if (itemEnabled==1){
					$(el).css({
						'border': '1px solid rgb(247,199,64)',
						'background': 'url("themes/' + param.theme + '/images/item.png") 0 0px repeat-x'
					});
				}
			},
			largeItemOut: function(el){
				itemEnabled = $(el).attr("itemEnabled");
				if (itemEnabled == 'undefined'){
					itemEnabled = 1;
				}
				if (itemEnabled==1){
					$(el).css({
						'border': '1px solid transparent',
						'background': 'transparent'
					});
				}
			},
			largeItemChecked: function(el){
				itemEnabled = $(el).attr("itemEnabled");
				if (itemEnabled == 'undefined'){
					itemEnabled = 1;
				}
				if (itemEnabled==1){
					$(el).css({
						'border': '1px solid rgb(247,199,64)',
						'background': 'url("themes/' + param.theme + '/images/item.png") 0 -192px repeat-x'
					});
				}
			},
			smallItemOver: function(el){
				itemEnabled = $(el).attr("itemEnabled");
				if (itemEnabled == 'undefined'){
					itemEnabled = 1;
				}
				if (itemEnabled==1){
					$(el).css({
						'border': '1px solid rgb(247,199,64)',
						'background': 'url("themes/' + param.theme + '/images/item.png") 0 -255px repeat-x'
					});
				}
			},
			smallItemOut: function(el){
				itemEnabled = $(el).attr("itemEnabled");
				if (itemEnabled == 'undefined'){
					itemEnabled = 1;
				}
				if (itemEnabled==1){
					$(el).css({
						'border': '1px solid transparent',
						'background': 'transparent'
					});
				}
			},
			smallItemChecked: function(el){
				itemEnabled = $(el).attr("itemEnabled");
				if (itemEnabled == 'undefined'){
					itemEnabled = 1;
				}
				if (itemEnabled==1){
					$(el).css({
						'border': '1px solid rgb(247,199,64)',
						'background': 'url("themes/' + param.theme + '/images/item.png") 0 -275px repeat-x'
					});	
				}
			},
			largeItemImageOver: function(el){
				itemID = $(el).attr("itemID");
				itemEnabled = $("#"+itemID).attr("itemEnabled");
				
				if (itemEnabled == 'undefined'){
					itemEnabled = 1;
				}
				
				if (itemEnabled==1){
					$("#"+itemID).css({
						'border': '1px solid rgb(247,199,64)'
					});
					$(el).css({
						'background': 'url("themes/' + param.theme + '/images/item.png") 0 -30px repeat-x'
					});
					$("#itemCaption-"+itemID).css({
						'border-top': '1px solid rgb(247,199,64)'
					});
				}
			},
			largeItemImageChecked: function(el){
				itemID = $(el).attr("itemID");
				itemEnabled = $("#"+itemID).attr("itemEnabled");
				
				if (itemEnabled == 'undefined'){
					itemEnabled = 1;
				}
				
				if (itemEnabled==1){
					$("#"+itemID).css({
						'border': '1px solid rgb(247,199,64)'
					});
					$(el).css({
						'background': 'url("themes/' + param.theme + '/images/item.png") 0 -192px repeat-x'
					});
					$("#itemCaption-"+itemID).css({
						'border-top': '1px solid rgb(247,199,64)'
					});
				}
			},
			largeItemImageOut: function(el){
				itemID = $(el).attr("itemID");
				itemEnabled = $("#"+itemID).attr("itemEnabled");
				
				if (itemEnabled == 'undefined'){
					itemEnabled = 1;
				}
				
				if (itemEnabled==1){
					$("#"+itemID).css({
						'border': '1px solid transparent'
					});
					$(el).css({
						'background': 'transparent'
					});
					$("#itemCaption-"+itemID).css({
						'border-top': '1px solid transparent'
					});
					$("#itemImage-"+itemID).css({
						'background': 'transparent'
					});
				}
			},
			largeItemCaptionOver: function(el){
				itemID = $(el).attr("itemID");
				itemEnabled = $("#"+itemID).attr("itemEnabled");
				
				if (itemEnabled == 'undefined'){
					itemEnabled = 1;
				}
				
				if (itemEnabled==1){
					$("#"+itemID).css({
						'border': '1px solid rgb(247,199,64)'
					});
					$(el).css({
						'border-top': '1px solid rgb(247,199,64)',
						'background': 'url("themes/' + param.theme + '/images/item.png") 0 -40px repeat-x'
					});
				}
			},
			largeItemCaptionChecked: function(el){
				itemID = $(el).attr("itemID");
				itemEnabled = $("#"+itemID).attr("itemEnabled");
				
				if (itemEnabled == 'undefined'){
					itemEnabled = 1;
				}
				
				if (itemEnabled==1){
					$("#"+itemID).css({
						'border': '1px solid rgb(247,199,64)'
					});
					$(el).css({
						'border-top': '1px solid rgb(247,199,64)',
						'background': 'url("themes/' + param.theme + '/images/item.png") 0 -192px repeat-x'
					});
					$("#itemImage-"+itemID).css({
						'background': 'url("themes/' + param.theme + '/images/item.png") 0 -192px repeat-x'
					});
				}
			},
			largeItemCaptionOut: function(el){
				itemID = $(el).attr("itemID");
				itemEnabled = $("#"+itemID).attr("itemEnabled");
				
				if (itemEnabled == 'undefined'){
					itemEnabled = 1;
				}
				
				if (itemEnabled==1){
					$("#"+itemID).css({
						'border': '1px solid transparent'
					});
					$(el).css({
						'border-top': '1px solid transparent',
						'background': 'transparent'
					});
				}
			},
			smallItemSplitOver: function(el){
				itemID = $(el).attr("itemID");
				itemEnabled = $("#"+itemID).attr("itemEnabled");
				
				if (itemEnabled == 'undefined'){
					itemEnabled = 1;
				}
				
				if (itemEnabled==1){
					$("#"+itemID).css({
						'border': '1px solid rgb(247,199,64)'
					});
					$('#itemImage-'+itemID).css({
						'background': 'url("themes/' + param.theme + '/images/item.png") 0 -255px repeat-x'
					});
					$('#itemCaption-'+itemID).css({
						'border-top': '0',
						'background': 'url("themes/' + param.theme + '/images/item.png") 0 -255px repeat-x'
					});
					$('#itemDropdown-'+itemID).css({
						'border-left': '1px solid rgb(247,199,64)'
					});
				}
			},
			smallItemSplitChecked: function(el){
				itemID = $(el).attr("itemID");
				itemEnabled = $("#"+itemID).attr("itemEnabled");
				
				if (itemEnabled == 'undefined'){
					itemEnabled = 1;
				}
				
				if (itemEnabled==1){
					$("#"+itemID).css({
						'border': '1px solid rgb(247,199,64)'
					});
					$('#itemImage-'+itemID).css({
						'background': 'url("themes/' + param.theme + '/images/item.png") 0 -192px repeat-x'
					});
					$('#itemCaption-'+itemID).css({
						'border-top': '0',
						'background': 'url("themes/' + param.theme + '/images/item.png") 0 -192px repeat-x'
					});
					$('#itemDropdown-'+itemID).css({
						'border-left': '1px solid rgb(247,199,64)'
					});
				}
			},
			smallItemSplitOut: function(el){
				itemID = $(el).attr("itemID");
				itemEnabled = $("#"+itemID).attr("itemEnabled");
				
				if (itemEnabled == 'undefined'){
					itemEnabled = 1;
				}
				
				if (itemEnabled==1){
					$("#"+itemID).css({
						'border': '1px solid transparent'
					});
					$('#itemImage-'+itemID).css({
						'background': 'transparent'
					});
					$('#itemCaption-'+itemID).css({
						'border-top': '0',
						'background': 'transparent'
					});
					$('#itemDropdown-'+itemID).css({
						'border-left': '1px solid transparent'
					});
				}
			},
			smallItemDropdownOver: function(el){
				itemID = $(el).attr("itemID");
				itemEnabled = $("#"+itemID).attr("itemEnabled");
				
				if (itemEnabled == 'undefined'){
					itemEnabled = 1;
				}
				
				if (itemEnabled==1){
					$("#"+itemID).css({
						'border': '1px solid rgb(247,199,64)'
					});
					$('#itemCaption-'+itemID).css({
						'border-top': '0'
					});
					$('#itemDropdown-'+itemID).css({
						'border-left': '1px solid rgb(247,199,64)',
						'background': 'url("themes/' + param.theme + '/images/item.png") 0 -255px repeat-x'
					});
				}
			},
			smallItemDropdownChecked: function(el){
				itemID = $(el).attr("itemID");
				itemEnabled = $("#"+itemID).attr("itemEnabled");
				
				if (itemEnabled == 'undefined'){
					itemEnabled = 1;
				}
				
				if (itemEnabled==1){
					$("#"+itemID).css({
						'border': '1px solid rgb(247,199,64)'
					});
					$('#itemImage-'+itemID).css({
						'background': 'url("themes/' + param.theme + '/images/item.png") 0 -192px repeat-x'
					});
					$('#itemCaption-'+itemID).css({
						'border-top': '0',
						'background': 'url("themes/' + param.theme + '/images/item.png") 0 -192px repeat-x'
					});
					$('#itemDropdown-'+itemID).css({
						'border-left': '1px solid rgb(247,199,64)',
						'background': 'url("themes/' + param.theme + '/images/item.png") 0 -192px repeat-x'
					});
				}
			},
			smallItemDropdownOut: function(el){
				itemID = $(el).attr("itemID");
				itemEnabled = $("#"+itemID).attr("itemEnabled");
				
				if (itemEnabled == 'undefined'){
					itemEnabled = 1;
				}
				
				if (itemEnabled==1){
					$("#"+itemID).css({
						'border': '1px solid transparent'
					});
					$('#itemImage-'+itemID).css({
						'background': 'transparent'
					});
					$('#itemCaption-'+itemID).css({
						'border-top': '0',
						'background': 'transparent'
					});
					$('#itemDropdown-'+itemID).css({
						'border-left': '1px solid transparent',
						'background': 'transparent'
					});
				}
			},
			resizeForm: function(){
				winHeight = document.documentElement.clientHeight;
				winWidth = document.documentElement.clientWidth;
				statusHeight = $("#statusbar").height();
				mainTop = $("#mainForm").position().top;
				mainHeight = winHeight - mainTop - statusHeight + 3;
				
				ribbonTop = $("#ribbonBar").position().top;
				
				$("#mainForm").height(mainHeight);
				
				$("#filePage").height(winHeight-ribbonTop-20);
				$("#filePageContent").height(winHeight-ribbonTop-23);
				$(".RightFileContent").height(winHeight-ribbonTop-23);
				
				$('#toolbarContainer').hide();
				
				if (selForm==undefined) selForm="";
				if (selForm=='undefined') selForm="";
				
				if (selForm != "") {
					formWidth = $('#form-'+selForm).width();
					formHeight = $('#form-'+selForm).height();
					
					centerWidth = (winWidth - formWidth) / 2;
					centerHeight =  (mainHeight - formHeight) / 2;
					
					if (centerWidth < 0){centerWidth = 0}
					if (centerHeight < 0){centerHeight = 0}
					
					$('#form-'+selForm).css({
						'margin-left': centerWidth + 'px',
						'margin-top': centerHeight + 'px'
					});	
					
					$('#toolbarContainer').show();
				} else {
					$('#toolbarContainer').hide();
					$('#staticForm').css("margin-top", ((mainHeight - $('#formLogo').height()) / 2) + "px");
				}
				
			},
			createForm: function(name){
				newName = name.replace(/_/g," ");
				
				strTab = "<li class='tabForms' id='" + name + "' formName='" + name +"'>";
				strTab += "<table><tr><td class='formTitle' formName='" + name +"'>" + newName + "&nbsp;&nbsp;&nbsp;" + "</td>"; 
				strTab += "<td class='formClose' formName='" + name +"'>&nbsp;</td></tr></table></li>";
				tabCount = $('.tabForms').length;
				
				blnFound = false;
				
				if (tabCount >=1 ){
					$('.tabForms').each(function(){
						$('.tabForms').removeClass('tabForms-select');
						frmName = $(this).attr('id');
						if (frmName == name){
							blnFound = true;
						}
					});
				} else {
					
				}
				
				if (blnFound == false){
					$("#tabForms").append(strTab);
				}
				
				$('#'+name).addClass('tabForms-select');
				selForm = name;
				
				ribbon.resizeForm();
				return blnFound;
			},
			selectForm: function(obj){
				name = $(obj).attr('formName');
				tabCount = $('.tabForms').length;
				
				if (tabCount >=1 ){
					$('.tabForms').each(function(){
						$('.tabForms').removeClass('tabForms-select');
					});
				}
				
				if (name != "") {
					$('#' + name).addClass('tabForms-select');
					$(".formContent").hide();
					$("#form-" + name).fadeIn();
					$('#toolbarContainer').show();
				}
				selForm = name;
				ribbon.resizeForm();
			},
			removeForm: function(obj){
				name = $(obj).attr('formName');
				selForm = "";
				
				$('#'+name).remove();
				$("#form-" + name).remove();
				
				if (tabCount >= 1 ){
					$('.tabForms').each(function(){
						formID =$(this).attr('id');
						if (formID != name){
							selForm = formID;
						}
					});
					
					el = $('#'+selForm);
					ribbon.selectForm(el);
				} else {
					selForm = ""; 
				}
				if (selForm == "") $("#staticForm").show();
				ribbon.resizeForm();
			},
			showForm: function(name){
				blnFound = ribbon.createForm(name);
				formContent = "";
				if (name!=''){
					if (blnFound==false){
						$.ajax({
							type: "GET",
							url: "forms/" + param.prefixForm + name + "." + param.extForm,
							dataType: "html",
							//beforeSend: function(){jWait();},
							//error: function(){jClose();},
							success: function(data){
								$(".formContent").hide();
								
								formContent = "<li class='formContent' id='form-" + name + "'>";
								formContent += data;
								formContent += "</li>";
								
								$("#mainForm").append(formContent);
								ribbon.resizeForm();
							}
						});
					} else {
						$(".formContent").hide();
						$("#form-" + name).fadeIn();
					}
					$("#staticForm").hide();
					ribbon.resizeForm();
				}
			},
			controlEvents: function() {
				$('.ribbonFile').live({
					click: function(){
						ribbon.selectFileTab();
						ribbon.resizeForm();
					}
				});
				$('.tabForms').live({
					mouseover: function(){
						formid = $(this).attr('id');
						$('.tabForms').removeClass('tabForms-hover');
						if (formid != selForm){
							$(this).addClass('tabForms-hover');
						}
					}
				});
				$('.formTitle').live({
					click: function(){
						ribbon.selectForm(this);
					}
				});
				$('.formClose').live({
					click: function(){
						ribbon.removeForm(this);
						ribbon.resizeForm();
					}
				});
				$('#mainFormContainer').live({
					click: function(){
						if (blnMinimized==1){
							$('#ribbonFrame-minimized').css('display', 'none');
						}
						ribbon.hidePopup(selItem);
					}
				});
				$('.ribbonTab').live({
					mouseover: function(){
						id = $(this).attr("id");
						//Hover if not selected tab
						if (id != selTab){
							$('#ribbonTab-left-tab-' + id).addClass("ribbonTab-left-hover");
							$('#ribbonTab-center-tab-' + id).addClass("ribbonTab-center-hover");
							$('#ribbonTab-right-tab-' + id).addClass("ribbonTab-right-hover");
						}
					},
					mouseout: function(){
						id = $(this).attr("id");
						$('#ribbonTab-left-tab-' + id).removeClass("ribbonTab-left-hover");
						$('#ribbonTab-center-tab-' + id).removeClass("ribbonTab-center-hover");
						$('#ribbonTab-right-tab-' + id).removeClass("ribbonTab-right-hover");
					},
					click: function(){
						ribbon.hidePopup(selItem);
						id = $(this).attr("id");
						ribbon.selectRibbonTab(id);
						
						ribbon.resizeForm();
					},
					dblclick: function(){
						ribbon.hidePopup(selItem);
						tmpTab = selTab;
						if (blnMinimized==0){
							$('#ribbonFrame-expand').css('display', 'none');
							$('#ribbonFrame-minimized').css('display', 'none');
							
							//Clear selected tab
							$('.ribbonTab-left-tab').removeClass("ribbonTab-left-select");
							$('.ribbonTab-center-tab').removeClass("ribbonTab-center-select");
							$('.ribbonTab-right-tab').removeClass("ribbonTab-right-select");
							
							selTab = 0;
							blnMinimized = 1;
						} else {
							$('#ribbonFrame-expand').css('display', 'block');
							$('#ribbonFrame-minimized').css('display', 'none');
							blnMinimized = 0;
							ribbon.selectRibbonTab(tmpTab);
						}
						ribbon.resizeForm();
					}
				});
				$('.ribbonItem').live({
					mouseover: function(){
						itemID = $(this).attr("id");
						itemType = $(this).attr("itemType");
						itemSize = $(this).attr("itemSize");
						itemChecked = $(this).attr("itemChecked");
						
						if (itemChecked == 'undefined'){
							itemChecked = -1;
						}
						
						switch (itemSize){
						case "large":
							if (itemType=='buttonsplitpopup'){
								
							} else if (itemType.substring(0,5) == 'popup'){
								ribbon.largeItemOver(this);
							} else if (itemType=='buttonpopup') {
								if (blnLock == 0){
									if (itemChecked == 0){
										ribbon.largeItemOver(this);
									} else if (itemChecked == 1){
										ribbon.largeItemChecked(this);
									} else {
										ribbon.largeItemOver(this);
									}
								} else { 
									if (itemID==selItem){
										ribbon.largeItemChecked(this);
									} else {
										ribbon.largeItemOut(this);
									}
								}
							} else if (itemType=='button') {
								if (blnLock == 0){
									if (itemChecked == 0){
										ribbon.largeItemOver(this);
									} else if (itemChecked == 1){
										ribbon.largeItemChecked(this);
									} else {
										ribbon.largeItemOver(this);
									}
									ribbon.showToolTip(obj);
								} else { 
									if (itemID==selItem){
										ribbon.largeItemChecked(this);
									} else {
										ribbon.largeItemOut(this);
									}
								}
							}
						break;
						case "medium":
							if (itemType=='buttonsplitpopup'){
								
							} else if (itemType.substring(0,5) == 'popup'){
								ribbon.largeItemOver(this);
							} else if (itemType=='buttonpopup') {
								if (blnLock == 0){
									if (itemChecked == 0){
										ribbon.largeItemOver(this);
									} else if (itemChecked == 1){
										ribbon.largeItemChecked(this);
									} else {
										ribbon.largeItemOver(this);
									}
								} else { 
									if (itemID==selItem){
										ribbon.largeItemChecked(this);
									} else {
										ribbon.largeItemOut(this);
									}
								}
							} else if (itemType=='button') {
								if (blnLock == 0){
									if (itemChecked == 0){
										ribbon.largeItemOver(this);
									} else if (itemChecked == 1){
										ribbon.largeItemChecked(this);
									} else {
										ribbon.largeItemOver(this);
									}
								} else { 
									if (itemID==selItem){
										ribbon.largeItemChecked(this);
									} else {
										ribbon.largeItemOut(this);
									}
								}
							}
						break;
						case "small":
							if (itemType.substring(0,5) == 'popup'){
								ribbon.smallItemOver(this);
							} else if (itemType=='buttonpopup'){
								if (blnLock == 0){
									if (itemChecked == 0){
										ribbon.smallItemOver(this);
									} else if (itemChecked == 1){
										ribbon.smallItemChecked(this);
									} else {
										ribbon.smallItemOver(this);
									}
								} else { 
									if (itemID==selItem){
										ribbon.smallItemChecked(this);
									} else {
										ribbon.smallItemOut(this);
									}
								}
							} else if (itemType=='button'){
								if (blnLock == 0){
									if (itemChecked == 0){
										ribbon.smallItemOver(this);
									} else if (itemChecked == 1){
										ribbon.smallItemChecked(this);
									} else {
										ribbon.smallItemOver(this);
									}
								} else { 
									if (itemID==selItem){
										ribbon.smallItemChecked(this);
									} else {
										ribbon.smallItemOut(this);
									}
								}
							}
						break;
						}
					},
					mouseout: function(){
						itemID = $(this).attr("id");
						itemType = $(this).attr("itemType");
						itemSize = $(this).attr("itemSize");
						itemChecked = $(this).attr("itemChecked");
						
						if (itemChecked == 'undefined'){
							itemChecked = -1;
						}
						
						switch (itemSize){
						case "large":
							if (itemType=='buttonsplitpopup'){
								
							} else if (itemType.substring(0,5) == 'popup'){
								ribbon.largeItemOut(this);
							} else if (itemType=='buttonpopup'){
								if (blnLock == 0){
									if (itemChecked == 0){
										ribbon.largeItemOut(this);
									} else if (itemChecked == 1){
										ribbon.largeItemChecked(this);
									} else {
										ribbon.largeItemOut(this);
									}
								} else {
									if (itemID==selItem){
										ribbon.largeItemChecked(this);
									} else {
										ribbon.largeItemOut(this);
									}
								}
							} else if (itemType=='button'){
								if (blnLock == 0){
									if (itemChecked == 0){
										ribbon.largeItemOut(this);
									} else if (itemChecked == 1){
										ribbon.largeItemChecked(this);
									} else {
										ribbon.largeItemOut(this);
									}
								} else {
									if (itemID==selItem){
										ribbon.largeItemChecked(this);
									} else {
										ribbon.largeItemOut(this);
									}
								}
							}
						break;
						case "medium":
							if (itemType=='buttonsplitpopup'){
								
							} else if (itemType.substring(0,5) == 'popup'){
								ribbon.largeItemOut(this);
							} else if (itemType=='buttonpopup'){
								if (blnLock == 0){
									if (itemChecked == 0){
										ribbon.largeItemOut(this);
									} else if (itemChecked == 1){
										ribbon.largeItemChecked(this);
									} else {
										ribbon.largeItemOut(this);
									}
								} else {
									if (itemID==selItem){
										ribbon.largeItemChecked(this);
									} else {
										ribbon.largeItemOut(this);
									}
								}
							} else if (itemType=='button'){
								if (blnLock == 0){
									if (itemChecked == 0){
										ribbon.largeItemOut(this);
									} else if (itemChecked == 1){
										ribbon.largeItemChecked(this);
									} else {
										ribbon.largeItemOut(this);
									}
								} else {
									if (itemID==selItem){
										ribbon.largeItemChecked(this);
									} else {
										ribbon.largeItemOut(this);
									}
								}
							}
						break;
						case "small":
							if (itemType=='buttonsplitpopup'){
								
							} else if (itemType.substring(0,5) == 'popup'){
								ribbon.smallItemOut(this);
							} else if (itemType=='buttonpopup'){
								if (blnLock == 0){
									if (itemChecked == 0){
										ribbon.smallItemOut(this);
									} else if (itemChecked == 1){
										ribbon.smallItemChecked(this);
									} else {
										ribbon.smallItemOut(this);
									}
								} else {
									if (itemID==selItem){
										ribbon.smallItemChecked(this);
									} else {
										ribbon.smallItemOut(this);
									}
								}
							} else if (itemType=='button'){
								if (blnLock == 0){
									if (itemChecked == 0){
										ribbon.smallItemOut(this);
									} else if (itemChecked == 1){
										ribbon.smallItemChecked(this);
									} else {
										ribbon.smallItemOut(this);
									}
								} else {
									if (itemID==selItem){
										ribbon.smallItemChecked(this);
									} else {
										ribbon.smallItemOut(this);
									}
								}
							}
						break;
						}
					},
					mousedown: function(){
						itemID = $(this).attr("id");
						itemType = $('#'+itemID).attr("itemType");
						itemSize = $('#'+itemID).attr("itemSize");
						itemChecked = $(this).attr("itemChecked");
						
						if (itemChecked == 'undefined'){
							itemChecked = -1;
						}
						
						switch (itemSize){
						case "large":
							if (itemType=='buttonsplitpopup'){
								
							} else if (itemType.substring(0,5) == 'popup'){
								ribbon.largeItemChecked(this);
							} else if (itemType=='buttonpopup'){
								if (blnLock == 0){
									blnLock = 1;
									ribbon.largeItemChecked(this);
									ribbon.showPopup(itemID);
									selItem = itemID;
								} else {
									ribbon.largeItemOver(this);
									ribbon.hidePopup(selItem);
									blnLock = 0;
									selItem = ""
								}
							} else if (itemType=='button') {
								if (blnLock == 0){
									ribbon.largeItemChecked(this);
								} else {
									ribbon.largeItemOver(this);
								}
							}
						break;
						case "medium":
							if (itemType=='buttonsplitpopup'){
								
							} else if (itemType.substring(0,5) == 'popup'){
								ribbon.largeItemChecked(this);
							} else if (itemType=='buttonpopup'){
								if (blnLock == 0){
									blnLock = 1;
									ribbon.largeItemChecked(this);
									ribbon.showPopup(itemID);
									selItem = itemID;
								} else {
									ribbon.largeItemOver(this);
									ribbon.hidePopup(selItem);
									blnLock = 0;
									selItem = ""
								}
							} else if (itemType=='button') {
								if (blnLock == 0){
									ribbon.largeItemChecked(this);
								} else {
									ribbon.largeItemOver(this);
								}
							}
						break;
						case "small":
							if (itemType=='buttonsplitpopup'){
								
							} else if (itemType.substring(0,5) == 'popup'){
								ribbon.smallItemChecked(this);
							} else if (itemType=='buttonpopup'){
								if (blnLock == 0){
									blnLock = 1;
									ribbon.largeItemChecked(this);
									ribbon.showPopup(itemID);
									selItem = itemID;
								} else {
									ribbon.largeItemOver(this);
									ribbon.hidePopup(selItem);
									blnLock = 0;
									selItem = ""
								}
							} else if (itemType=='button') {
								if (blnLock == 0){
									ribbon.smallItemChecked(this);
								} else {
									ribbon.smallItemOver(this);
								}
							}
						break;
						}
					},
					mouseup: function(){
						itemID = $(this).attr("id");
						itemType = $('#'+itemID).attr("itemType");
						itemSize = $('#'+itemID).attr("itemSize");
						itemChecked = $(this).attr("itemChecked");
						
						if (itemChecked == 'undefined'){
							itemChecked = -1;
						}
						
						switch (itemSize){
						case "medium":
							if (itemType=='buttonsplitpopup'){
								
							} else if (itemType.substring(0,5) == 'popup'){
								ribbon.largeItemOver(this);
							} else if (itemType=='buttonpopup'){
								if (blnLock == 0){
									ribbon.largeItemOver(this);
								} else {
									ribbon.largeItemChecked(this);
								}
							} else if (itemType=='button') {
								if (blnLock == 0){
									ribbon.largeItemOver(this);
								} else {
									ribbon.largeItemOver(this);
								}
							}
						break;
						case "medium":
							if (itemType=='buttonsplitpopup'){
								
							} else if (itemType.substring(0,5) == 'popup'){
								ribbon.largeItemOver(this);
							} else if (itemType=='buttonpopup'){
								if (blnLock == 0){
									ribbon.largeItemOver(this);
								} else {
									ribbon.largeItemChecked(this);
								}
							} else if (itemType=='button') {
								if (blnLock == 0){
									ribbon.largeItemOver(this);
								} else {
									ribbon.largeItemOver(this);
								}
							}
						break;
						case "small":
							if (itemType=='buttonsplitpopup'){
								
							} else if (itemType.substring(0,5) == 'popup'){
								ribbon.smallItemOver(this);
							} else if (itemType=='buttonpopup'){
								if (blnLock == 0){
									ribbon.smallItemOver(this);
								} else {
									ribbon.smallItemChecked(this);
								}
							} else if (itemType=='button') {
								if (blnLock == 0){
									ribbon.smallItemOver(this);
								} else {
									ribbon.smallItemOver(this);
								}
							}
						break;
						}
					},
					click: function(){
						itemID = $(this).attr("id");
						itemType = $('#'+itemID).attr("itemType");
						itemSize = $('#'+itemID).attr("itemSize");
						itemChecked = $(this).attr("itemChecked");
						itemEnabled = $(this).attr("itemEnabled");
						itemName = $(this).attr("itemName");
						
						if (itemChecked == 'undefined'){
							itemChecked = -1;
						}
						
						if (itemEnabled != 0){
							switch (itemSize){
							case "large":
								if (itemType.substring(0,5) == 'popup'){
									ribbon.hidePopup(selItem);
									blnLock = 0;
									selItem = "";
									ribbon.onClick(this);
								} else if (itemType=='button') {
									if (blnLock == 0){
										if (itemChecked == 0){
											ribbon.largeItemOver(this);
											$(this).attr("itemChecked", 1);
										} else if (itemChecked == 1){
											ribbon.largeItemOver(this);
											$(this).attr("itemChecked", 0);
										}
										ribbon.onClick(this);
									} else {
										ribbon.largeItemOver(this);
									}
								}
							break;
							case "medium":
								if (itemType.substring(0,5) == 'popup'){
									ribbon.hidePopup(selItem);
									blnLock = 0;
									selItem = "";
									ribbon.onClick(this);
								} else if (itemType=='button') {
									if (blnLock == 0){
										if (itemChecked == 0){
											ribbon.largeItemOver(this);
											$(this).attr("itemChecked", 1);
										} else if (itemChecked == 1){
											ribbon.largeItemOver(this);
											$(this).attr("itemChecked", 0);
										}
										ribbon.onClick(this);
									} else {
										ribbon.largeItemOver(this);
									}
								}
							break;
							case "small":
								if (itemType.substring(0,5) == 'popup'){
									var itemSel = $('#'+selItem).attr("itemType");
									
									if (itemSel=="combo"){
										var strCap = $('#itemLabel-'+itemID).html();
										
										itemName = $('#ribbonCombo-'+selItem).attr("itemName");
										
										$('#ribbonCombo-'+selItem).val(strCap);
										param.onChange($('#ribbonCombo-'+selItem));
										
										$('.ribbonCombo').each(function(){
											var itemNames = $(this).attr("itemName");
											if (itemNames == itemName) {
												$(this).val(strCap);
											}
										});
									}
									
									ribbon.hidePopup(selItem);
									
									blnLock = 0;
									selItem = "";
									ribbon.onClick(this);
									
								} else if (itemType=='button') {
									if (blnLock == 0){
										if (itemChecked == 0){
											ribbon.largeItemOver(this);
											itemChecked = 1;
										} else if (itemChecked == 1){
											ribbon.largeItemOver(this);
											itemChecked = 0;
										}
										$(this).attr("itemChecked", itemChecked);
										ribbon.onClick(this);
									} else {
										ribbon.largeItemOver(this);
									}
								} else if (itemType=='check') {
									
									$('.ribbonItem').each(function(){
										//if (itemTypes=='check'){
										var itemNames = $(this).attr("itemName");
										if (itemNames == itemName) {
											var itemIDs = $(this).attr("itemID");
											$(this).attr("itemChecked", itemChecked);
											if (itemChecked == 0){
												$('#itemImage-'+itemIDs).css({
													'background': 'url("themes/' + param.theme + '/images/checkbox.png") 0px 4px repeat-x'
												});
											} else if (itemChecked == 1){
												$('#itemImage-'+itemIDs).css({
													'background': 'url("themes/' + param.theme + '/images/checkbox.png") -26px 4px repeat-x'
												});
											}
										}
									});
									if (blnLock == 0){
										ribbon.onClick(this);
									}
								}
								
									
							break;
							}
						}
						
					}
				});
				$('.optionButton').live({
					click: function(){
						ribbon.onClick(this);
					}
				});
				$('.itemImage').live({
					mouseover: function(){
						itemID = $(this).attr("itemID");
						itemType = $('#'+itemID).attr("itemType");
						itemSize = $('#'+itemID).attr("itemSize");
						itemChecked = $('#'+itemID).attr("itemChecked");
						itemEnabled = $('#'+itemID).attr("itemEnabled");
						
						if (itemChecked == 'undefined'){
							itemChecked = -1;
						}
						
						switch (itemSize){
						case "large":
							if (itemType=='buttonsplitpopup'){
								if (blnLock == 0){
									if (itemChecked == 0){
										ribbon.largeItemImageOver(this);
									} else if (itemChecked == 1){
										ribbon.largeItemImageChecked(this);
									} else {
										ribbon.largeItemImageOver(this);
									}
								} else { 
									if (itemID==selItem){
										ribbon.largeItemImageChecked(this);
									} else {
										ribbon.largeItemImageOut(this);
									}
								}
							}
						break;
						case "small":
							if (itemType=='buttonsplitpopup'){
								if (blnLock == 0){
									if (itemChecked == 0){
										ribbon.smallItemSplitOver(this);
									} else if (itemChecked == 1){
										ribbon.smallItemSplitChecked(this);
									} else {
										ribbon.smallItemSplitOver(this);
									}
								} else { 
									if (itemID==selItem){
										ribbon.smallItemSplitChecked(this);
									} else {
										ribbon.smallItemSplitOut(this);
									}
								}
							} else if (itemType=='check'){
								if (blnLock == 0){
									if (itemEnabled==0){
										
									} else {
										if (itemChecked == 0){
											$('#itemImage-'+itemID).css({
												'background': 'url("themes/' + param.theme + '/images/checkbox.png") -13px 4px repeat-x'
											});
										} else if (itemChecked == 1){
											$('#itemImage-'+itemID).css({
												'background': 'url("themes/' + param.theme + '/images/checkbox.png") -39px 4px repeat-x'
											});
										}	
									}
								} else { 
									if (itemEnabled==0){
									} else {
										if (itemChecked == 0){
											$('#itemImage-'+itemID).css({
												'background': 'url("themes/' + param.theme + '/images/checkbox.png") 0px 4px repeat-x'
											});
										} else if (itemChecked == 1){
											$('#itemImage-'+itemID).css({
												'background': 'url("themes/' + param.theme + '/images/checkbox.png") -26px 4px repeat-x'
											});
										}
									}
								}
							}
						break;
						}
					},
					mouseout: function(){
						itemID = $(this).attr("itemID");
						itemType = $('#'+itemID).attr("itemType");
						itemSize = $('#'+itemID).attr("itemSize");
						itemChecked = $('#'+itemID).attr("itemChecked");
						itemEnabled = $('#'+itemID).attr("itemEnabled");
						
						if (itemChecked == 'undefined'){
							itemChecked = -1;
						}
						
						switch (itemSize){
						case "large":
							if (itemType=='buttonsplitpopup'){
								if (blnLock == 0){
									if (itemChecked == 0){
										ribbon.largeItemImageOut(this);
									} else if (itemChecked == 1){
										ribbon.largeItemImageChecked(this);
									} else {
										ribbon.largeItemImageOut(this);
									}
								} else {
									if (itemID==selItem){
										ribbon.largeItemImageChecked(this);
									} else {
										ribbon.largeItemImageOut(this);
									}
								}
							}
						break;
						case "small":
							if (itemType=='buttonsplitpopup'){
								if (blnLock == 0){
									if (itemChecked == 0){
										ribbon.smallItemSplitOut(this);
									} else if (itemChecked == 1){
										ribbon.smallItemSplitChecked(this);
									} else {
										ribbon.smallItemSplitOut(this);
									}
								} else {
									if (itemID==selItem){
										ribbon.smallItemSplitChecked(this);
									} else {
										ribbon.smallItemSplitOut(this);
									}
								}
							} else if (itemType=='check'){
								if (blnLock == 0){
									if (itemEnabled==0){
										
									} else {
										if (itemChecked == 0){
											$('#itemImage-'+itemID).css({
												'background': 'url("themes/' + param.theme + '/images/checkbox.png") 0px 4px repeat-x'
											});
										} else if (itemChecked == 1){
											$('#itemImage-'+itemID).css({
												'background': 'url("themes/' + param.theme + '/images/checkbox.png") -26px 4px repeat-x'
											});
										}
									}
								} else {
									if (itemEnabled==0){
									} else {
										if (itemChecked == 0){
											$('#itemImage-'+itemID).css({
												'background': 'url("themes/' + param.theme + '/images/checkbox.png") 0px 4px repeat-x'
											});
										} else if (itemChecked == 1){
											$('#itemImage-'+itemID).css({
												'background': 'url("themes/' + param.theme + '/images/checkbox.png") -26px 4px repeat-x'
											});
										}
									}
								}
							}
						break;
						}
					},
					mousedown: function(){
						itemID = $(this).attr("itemID");
						itemType = $('#'+itemID).attr("itemType");
						itemSize = $('#'+itemID).attr("itemSize");
						itemChecked = $('#'+itemID).attr("itemChecked");
						itemEnabled = $('#'+itemID).attr("itemEnabled");
						
						if (itemChecked == 'undefined'){
							itemChecked = -1;
						}
						
						switch (itemSize){
						case "large":
							if (itemType=='buttonsplitpopup') {
								if (blnLock == 0){
									ribbon.largeItemImageChecked(this);
								} else {
									ribbon.largeItemImageOver(this);
								}
							}
						break;
						case "small":
							if (itemType=='buttonsplitpopup') {
								if (blnLock == 0){
									ribbon.smallItemSplitChecked(this);
								} else {
									ribbon.smallItemSplitOver(this);
								}
							} else if (itemType=='check'){
								if (blnLock == 0){
									if (itemEnabled==0){
										
									} else {
										if (itemChecked == 0){
											$(this).css({
												'background': 'url("themes/' + param.theme + '/images/checkbox.png") -39px 4px repeat-x'
											});
											itemChecked = 1;
										} else if (itemChecked == 1){
											$(this).css({
												'background': 'url("themes/' + param.theme + '/images/checkbox.png") -13px 4px repeat-x'
											});
											itemChecked = 0;
										}
										$(this).attr("itemChecked", itemChecked);
										$('#'+itemID).attr("itemChecked", itemChecked);
										$('#itemCaption-'+itemID).attr("itemChecked", itemChecked);
									}
								} else { 
									ribbon.smallItemSplitOut(this);
								}
							}
						break;
						}
					},
					mouseup: function(){
						itemID = $(this).attr("itemID");
						itemType = $('#'+itemID).attr("itemType");
						itemSize = $('#'+itemID).attr("itemSize");
						itemChecked = $('#'+itemID).attr("itemChecked");
						
						if (itemChecked == 'undefined'){
							itemChecked = -1;
						}
						
						switch (itemSize){
						case "large":
							if (itemType=='buttonsplitpopup'){
								if (blnLock == 0){
									ribbon.largeItemImageOver(this);
								} else {
									ribbon.largeItemImageOver(this);
								}
							}
						break;
						case "small":
							if (itemType=='buttonsplitpopup'){
								if (blnLock == 0){
									ribbon.smallItemSplitOver(this);
								} else {
									ribbon.smallItemSplitOver(this);
								}
							}
						break;
						}
					}
				});
				$('.itemCaption').live({
					mouseover: function(){
						itemID = $(this).attr("itemID");
						itemType = $('#'+itemID).attr("itemType");
						itemSize = $('#'+itemID).attr("itemSize");
						itemChecked = $('#'+itemID).attr("itemChecked");
						itemEnabled = $('#'+itemID).attr("itemEnabled");
						
						if (itemChecked == 'undefined'){
							itemChecked = -1;
						}
						
						switch (itemSize){
						case "large":
							if (itemType=='buttonsplitpopup'){
								if (blnLock == 0){
									if (itemChecked == 0){
										ribbon.largeItemCaptionOver(this);
									} else if (itemChecked == 1){
										ribbon.largeItemCaptionChecked(this);
									} else {
										ribbon.largeItemCaptionOver(this);
									}
								} else { 
									if (itemID==selItem){
										ribbon.largeItemCaptionChecked(this);
									} else {
										ribbon.largeItemCaptionOut(this);
									}
								}
							}
						break;
						case "small":
							if (itemType=='buttonsplitpopup'){
								if (blnLock == 0){
									if (itemChecked == 0){
										ribbon.smallItemSplitOver(this);
									} else if (itemChecked == 1){
										ribbon.smallItemSplitChecked(this);
									} else {
										ribbon.smallItemSplitOver(this);
									}
								} else { 
									if (itemID==selItem){
										ribbon.smallItemSplitChecked(this);
									} else {
										ribbon.smallItemSplitOut(this);
									}
								}
							} else if (itemType=='check'){
								if (blnLock == 0){
									if (itemEnabled==0){
										
									} else {
										if (itemChecked == 0){
											$('#itemImage-'+itemID).css({
												'background': 'url("themes/' + param.theme + '/images/checkbox.png") -13px 4px repeat-x'
											});
										} else if (itemChecked == 1){
											$('#itemImage-'+itemID).css({
												'background': 'url("themes/' + param.theme + '/images/checkbox.png") -39px 4px repeat-x'
											});
										}
									}
								} else {
									if (itemEnabled==0){
									} else {
										if (itemChecked == 0){
											$('#itemImage-'+itemID).css({
												'background': 'url("themes/' + param.theme + '/images/checkbox.png") 0px 4px repeat-x'
											});
										} else if (itemChecked == 1){
											$('#itemImage-'+itemID).css({
												'background': 'url("themes/' + param.theme + '/images/checkbox.png") -26px 4px repeat-x'
											});
										}
									}
								}
							}
						break;
						}
					},
					mouseout: function(){
						itemID = $(this).attr("itemID");
						itemType = $('#'+itemID).attr("itemType");
						itemSize = $('#'+itemID).attr("itemSize");
						itemChecked = $('#'+itemID).attr("itemChecked");
						itemEnabled = $('#'+itemID).attr("itemEnabled");
						
						if (itemChecked == 'undefined'){
							itemChecked = -1;
						}
						
						switch (itemSize){
						case "large":
							if (itemType=='buttonsplitpopup'){
								if (blnLock == 0){
									if (itemChecked == 0){
										ribbon.largeItemCaptionOut(this);
									} else if (itemChecked == 1){
										ribbon.largeItemCaptionChecked(this);
									} else {
										ribbon.largeItemCaptionOut(this);
									}
								} else {
									if (itemID==selItem){
										ribbon.largeItemCaptionChecked(this);
									} else {
										ribbon.largeItemCaptionOut(this);
									}
								}
							}
						break;
						case "small":
							if (itemType=='buttonsplitpopup'){
								if (blnLock == 0){
									if (itemChecked == 0){
										ribbon.smallItemSplitOut(this);
									} else if (itemChecked == 1){
										ribbon.smallItemSplitChecked(this);
									} else {
										ribbon.smallItemSplitOut(this);
									}
								} else {
									if (itemID==selItem){
										ribbon.smallItemSplitChecked(this);
									} else {
										ribbon.smallItemSplitOut(this);
									}
								}
							} else if (itemType=='check'){
								if (blnLock == 0){
									if (itemEnabled==0){
										
									} else {
										if (itemChecked == 0){
											$('#itemImage-'+itemID).css({
												'background': 'url("themes/' + param.theme + '/images/checkbox.png") 0px 4px repeat-x'
											});
										} else if (itemChecked == 1){
											$('#itemImage-'+itemID).css({
												'background': 'url("themes/' + param.theme + '/images/checkbox.png") -26px 4px repeat-x'
											});
										}
									}
								} else { 
									if (itemEnabled==0){
									} else {
										if (itemChecked == 0){
											$('#itemImage-'+itemID).css({
												'background': 'url("themes/' + param.theme + '/images/checkbox.png") 0px 4px repeat-x'
											});
										} else if (itemChecked == 1){
											$('#itemImage-'+itemID).css({
												'background': 'url("themes/' + param.theme + '/images/checkbox.png") -26px 4px repeat-x'
											});
										}
									}
								}
							}
						break;
						}
					},
					mousedown: function(){
						itemID = $(this).attr("itemID");
						itemType = $('#'+itemID).attr("itemType");
						itemSize = $('#'+itemID).attr("itemSize");
						itemChecked = $('#'+itemID).attr("itemChecked");
						itemEnabled = $('#'+itemID).attr("itemEnabled");
						
						if (itemChecked == 'undefined'){
							itemChecked = -1;
						}
						
						switch (itemSize){
						case "large":
							if (itemType=='buttonsplitpopup') {
								if (blnLock == 0){
									blnLock = 1;
									ribbon.largeItemCaptionChecked(this);
									ribbon.showPopup(itemID);
									selItem = itemID;
								} else {
									ribbon.largeItemCaptionOver(this);
									ribbon.hidePopup(selItem);
									blnLock = 0;
									selItem = ""
								}
							}
						break;
						case "small":
							if (itemType=='buttonsplitpopup') {
								if (blnLock == 0){
									ribbon.smallItemSplitChecked(this);
								} else {
									ribbon.smallItemSplitOver(this);
								}
							} else if (itemType=='check'){
								if (blnLock == 0){
									if (itemEnabled==0){
										
									} else {
										if (itemChecked == 0){
											$('#itemImage-'+itemID).css({
												'background': 'url("themes/' + param.theme + '/images/checkbox.png") -39px 4px repeat-x'
											});
											itemChecked = 1;
										} else if (itemChecked == 1){
											$('#itemImage-'+itemID).css({
												'background': 'url("themes/' + param.theme + '/images/checkbox.png") -13px 4px repeat-x'
											});
											itemChecked = 0;
										}
										$(this).attr("itemChecked", itemChecked);
										$('#'+itemID).attr("itemChecked", itemChecked);
										$('#itemCaption-'+itemID).attr("itemChecked", itemChecked);
									}
								} else { 
									ribbon.smallItemSplitOut(this);
								}
							}
						break;
						}
					},
					mouseup: function(){
						itemID = $(this).attr("itemID");
						itemType = $('#'+itemID).attr("itemType");
						itemSize = $('#'+itemID).attr("itemSize");
						itemChecked = $('#'+itemID).attr("itemChecked");
						
						if (itemChecked == 'undefined'){
							itemChecked = -1;
						}
						
						switch (itemSize){
						case "large":
							if (itemType=='buttonsplitpopup'){
								if (blnLock == 0){
									ribbon.largeItemCaptionOut(this);
									ribbon.largeItemCaptionOver(this);
									ribbon.largeItemImageOut(this);
								} else {
									ribbon.largeItemCaptionChecked(this);
								}
							}
						break;
						case "small":
							if (itemType=='buttonsplitpopup'){
								if (blnLock == 0){
									ribbon.smallItemSplitOver(this);
								} else {
									ribbon.smallItemSplitOver(this);
								}
							}
						break;
						}
					}
				});
				$('.itemDropdown').live({
					mouseover: function(){
						itemID = $(this).attr("itemID");
						itemType = $('#'+itemID).attr("itemType");
						itemSize = $('#'+itemID).attr("itemSize");
						itemChecked = $('#'+itemID).attr("itemChecked");
						
						if (itemChecked == 'undefined'){
							itemChecked = -1;
						}
						
						switch (itemSize){
						case "large":
							
						break;
						case "small":
							if (itemType=='buttonsplitpopup'){
								if (blnLock == 0){
									if (itemChecked == 0){
										ribbon.smallItemDropdownOver(this);
									} else if (itemChecked == 1){
										ribbon.smallItemDropdownChecked(this);
									} else {
										ribbon.smallItemDropdownOver(this);
									}
								} else { 
									if (itemID==selItem){
										ribbon.smallItemDropdownChecked(this);
									} else {
										ribbon.smallItemDropdownOut(this);
									}
								}
							}
						break;
						}
					},
					mouseout: function(){
						itemID = $(this).attr("itemID");
						itemType = $('#'+itemID).attr("itemType");
						itemSize = $('#'+itemID).attr("itemSize");
						itemChecked = $('#'+itemID).attr("itemChecked");
						
						if (itemChecked == 'undefined'){
							itemChecked = -1;
						}
						
						switch (itemSize){
						case "large":
							
						break;
						case "small":
							if (itemType=='buttonsplitpopup'){
								if (blnLock == 0){
									if (itemChecked == 0){
										ribbon.smallItemDropdownOut(this);
									} else if (itemChecked == 1){
										ribbon.smallItemDropdownChecked(this);
									} else {
										ribbon.smallItemDropdownOut(this);
									}
								} else {
									if (itemID==selItem){
										ribbon.smallItemDropdownChecked(this);
									} else {
										ribbon.smallItemDropdownOut(this);
									}
								}
							}
						break;
						}
					},
					mousedown: function(){
						itemID = $(this).attr("itemID");
						itemType = $('#'+itemID).attr("itemType");
						itemSize = $('#'+itemID).attr("itemSize");
						itemChecked = $('#'+itemID).attr("itemChecked");
						
						if (itemChecked == 'undefined'){
							itemChecked = -1;
						}
						
						switch (itemSize){
						case "large":
							
						break;
						case "small":
							if (itemType=='buttonsplitpopup') {
								if (blnLock == 0){
									blnLock = 1;
									ribbon.smallItemDropdownChecked(this);
									ribbon.showPopup(itemID);
									selItem = itemID;
								} else {
									ribbon.smallItemDropdownOver(this);
									ribbon.hidePopup(selItem);
									blnLock = 0;
									selItem = ""
								}
							}
						break;
						}
					},
					mouseup: function(){
						itemID = $(this).attr("itemID");
						itemType = $('#'+itemID).attr("itemType");
						itemSize = $('#'+itemID).attr("itemSize");
						itemChecked = $('#'+itemID).attr("itemChecked");
						
						if (itemChecked == 'undefined'){
							itemChecked = -1;
						}
						
						switch (itemSize){
						case "large":
							
						break;
						case "small":
							if (itemType=='buttonsplitpopup'){
								if (blnLock == 0){
									ribbon.smallItemSplitOut(this);
									ribbon.smallItemDropdownOver(this);
								} else {
									ribbon.smallItemDropdownChecked(this);
								}
							}
						break;
						}
					},
					click: function(){
						itemID = $(this).attr("id");
						itemType = $('#'+itemID).attr("itemType");
						itemSize = $('#'+itemID).attr("itemSize");
						itemChecked = $(this).attr("itemChecked");
						
						if (itemChecked == 'undefined'){
							itemChecked = -1;
						}
						
						switch (itemSize){
						case "large":
							
						break;
						case "small":
							
						break;
						}
					}
				});
				$('#ribbonContainer').live({
					scroll: function(){
						
					}
				});
				$('.ribbonButonSpinUp').live({
					mousedown: function(){
						var itemID = $(this).attr("itemID");
						var itemVal = $("#ribbonInputSpin-"+itemID).val();
						var itemName = $("#ribbonInputSpin-"+itemID).attr("itemName");
						
						$(this).css('background','url("themes/' + param.theme + '/images/spin.png") 0px -43px no-repeat');
						
						if (itemVal==undefined) itemVal = 0;
						if (itemVal=='undefined') itemVal = 0;
						if (itemVal=='') itemVal = 0;
						itemVal = parseInt(itemVal);
						var newVal = itemVal + 1;
						
						$('.ribbonInputSpin').each(function(){
							var itemNames = $(this).attr("itemName");
							if (itemNames == itemName) {
								$(this).val(newVal);
								param.onChange($(this));
							}
						});
						
						$('#ribbonInputSpin-'+itemID).val(newVal);
						
					}, 
					mouseover: function(){
						$(this).css('background','url("themes/' + param.theme + '/images/spin.png") 0px -22px no-repeat');
					}, 
					mouseout: function(){
						$(this).css('background','url("themes/' + param.theme + '/images/spin.png") 0px 0px no-repeat');
					}
				});
				$('.ribbonButonSpinDn').live({
					mousedown: function(){
						var itemID = $(this).attr("itemID");
						var itemName = $("#ribbonInputSpin-"+itemID).attr("itemName");
						var itemVal = $("#ribbonInputSpin-"+itemID).val();
						
						$(this).css('background','url("themes/' + param.theme + '/images/spin.png") 0px -53px no-repeat');
						
						if (itemVal==undefined) itemVal = 0;
						if (itemVal=='undefined') itemVal = 0;
						if (itemVal=='') itemVal = 0;
						itemVal = parseInt(itemVal);
						var newVal = itemVal - 1;
						
						$('.ribbonInputSpin').each(function(){
							var itemNames = $(this).attr("itemName");
							if (itemNames == itemName) {
								$(this).val(newVal);
								param.onChange($(this));
							}
						});
						//$('#ribbonInputSpin-'+itemID).val(newVal);
					}, 
					mouseover: function(){
						$(this).css('background','url("themes/' + param.theme + '/images/spin.png") 0px -32px no-repeat');
					}, 
					mouseout: function(){
						$(this).css('background','url("themes/' + param.theme + '/images/spin.png") 0px -10px no-repeat');
					}
				});
				$('.ribbonCombo').live({
					mouseover: function(){
						var itemID = $(this).attr("itemID");
						if (blnLock == 0){
							$("#comboDropdown-"+itemID).css({
								'background':'url("themes/' + param.theme + '/images/combo.png") 0px -22px no-repeat'
							});
						}
					}, 
					mousedown: function(){
						
					}, 
					mouseout: function(){
						if (blnLock == 0){
							var itemID = $(this).attr("itemID");
							$("#comboDropdown-"+itemID).css({
								'background':'url("themes/' + param.theme + '/images/combo.png") 0px 0px no-repeat'
							});
						}
					}
				});
				$('.comboDropdown').live({
					mouseover: function(){
						var itemID = $(this).attr("itemID");
						
						if (blnLock == 0){
							$("#comboDropdown-"+itemID).css({
								'background':'url("themes/' + param.theme + '/images/combo.png") 0px -44px no-repeat'
							});
						} else { 
							if (itemID==selItem){
								$("#comboDropdown-"+itemID).css({
									'background':'url("themes/' + param.theme + '/images/combo.png") 0px -66px no-repeat'
								});
							} else {
								$("#comboDropdown-"+itemID).css({
									'background':'url("themes/' + param.theme + '/images/combo.png") 0px 0px no-repeat'
								});
							}
						}
					}, 
					mouseout: function(){
						var itemID = $(this).attr("itemID");
						if (blnLock == 0){
							$("#comboDropdown-"+itemID).css({
								'background':'url("themes/' + param.theme + '/images/combo.png") 0px 0px no-repeat'
							});
						} else {
							if (itemID==selItem){
								$("#comboDropdown-"+itemID).css({
									'background':'url("themes/' + param.theme + '/images/combo.png") 0px -66px no-repeat'
								});
							} else {
								$("#comboDropdown-"+itemID).css({
									'background':'url("themes/' + param.theme + '/images/combo.png") 0px 0px no-repeat'
								});
							}
						}
						
					},
					mousedown: function(){
						var itemID = $(this).attr("itemID");
						if (blnLock == 0){
							blnLock = 1;
							$("#comboDropdown-"+itemID).css({
								'background':'url("themes/' + param.theme + '/images/combo.png") 0px -66px no-repeat'
							});
							ribbon.showPopup(itemID);
							selItem = itemID;
						} else {
							$("#comboDropdown-"+itemID).css({
								'background':'url("themes/' + param.theme + '/images/combo.png") 0px -44px no-repeat'
							});
							ribbon.hidePopup(selItem);
							blnLock = 0;
							selItem = ""
						}
					},
					mouseup: function(){
						var itemID = $(this).attr("itemID");
						if (blnLock == 0){
							$("#comboDropdown-"+itemID).css({
								'background':'url("themes/' + param.theme + '/images/combo.png") 0px -44px no-repeat'
							});
						} else {
							$("#comboDropdown-"+itemID).css({
								'background':'url("themes/' + param.theme + '/images/combo.png") 0px -66px no-repeat'
							});
						}
					}
				});
				$('.gallery-scroll-top').live({
					mouseover: function(){
						$(this).css({
							'border': '1px solid rgb(247,199,64)',
							'background':'url("themes/' + param.theme + '/images/gallery-scroll.png") 0px -109px no-repeat'
						});
					},
					mouseout: function(){
						$(this).css({
							'border': '1px solid rgb(140,142,145)',
							'background':'url("themes/' + param.theme + '/images/gallery-scroll.png") 0px 0px no-repeat'
						});
					},
					mousedown: function(){
						$(this).css({
							'border': '1px solid rgb(247,199,64)',
							'background':'url("themes/' + param.theme + '/images/gallery-scroll.png") 0px -54px no-repeat'
						});
						
						itemID = $(this).attr('itemID');
						
						itemSel = '#'+'divGalleryContainer-'+itemID;
						itemHeight = $(itemSel).height();
						el = $(itemSel);
						elScrollHeight =  el[0].scrollHeight;
						maxScroll = elScrollHeight - itemHeight;
						
						maxItem = maxScroll / itemHeight;
						
						if (arrScroll[itemID]==undefined){
							arrScroll[itemID] = 0;
						}
						
						arrScroll[itemID] -= 1;
						
						itemVal = arrScroll[itemID];
						
						if (itemVal < 0 ){itemVal = 0;}
						
						arrScroll['Max-'+itemID] = itemVal;
						el[0].scrollTop = itemVal * (itemHeight);
					},
					mouseup: function(){
						$(this).css({
							'border': '1px solid rgb(140,142,145)',
							'background': 'url("themes/' + param.theme + '/images/gallery-scroll.png") 0px 0px no-repeat'
						});
					}
				});
				$('.gallery-scroll-bottom').live({
					mouseover: function(){
						$(this).css({
							'border': '1px solid rgb(247,199,64)',
							'background':'url("themes/' + param.theme + '/images/gallery-scroll.png") 0px -127px no-repeat'
						});
					},
					mouseout: function(){
						$(this).css({
							'border': '1px solid rgb(140,142,145)',
							'background':'url("themes/' + param.theme + '/images/gallery-scroll.png") 0px -17px no-repeat'
						});
					},
					mousedown: function(){
						$(this).css({
							'border': '1px solid rgb(247,199,64)',
							'background':'url("themes/' + param.theme + '/images/gallery-scroll.png") 0px -73px no-repeat'
						});
						
						itemID = $(this).attr('itemID');
						itemSel = '#'+'divGalleryContainer-'+itemID;
						itemHeight = $(itemSel).height();
						el = $(itemSel);
						elScrollHeight =  el[0].scrollHeight;
						
						maxItem = ribbon.divide(elScrollHeight, itemHeight);
						
						if (arrScroll[itemID]==undefined){
							arrScroll[itemID] = 0;
						}
						
						arrScroll[itemID] += 1;
						
						itemVal = arrScroll[itemID];
						
						if (itemVal >= maxItem){itemVal = maxItem;}
						
						arrScroll[itemID] = itemVal;
						el[0].scrollTop = (itemVal) * (itemHeight);
					},
					mouseup: function(){
						$(this).css({
							'border': '1px solid rgb(140,142,145)',
							'background': 'url("themes/' + param.theme + '/images/gallery-scroll.png") 0px -17px no-repeat'
						});
					}
				});
				$('.gallery-scroll-popup').live({
					mouseover: function(){
						$(this).css({
							'border': '1px solid rgb(247,199,64)',
							'background':'url("themes/' + param.theme + '/images/gallery-scroll.png") 0px -144px no-repeat'
						});
					},
					mouseout: function(){
						$(this).css({
							'border': '1px solid rgb(140,142,145)',
							'background':'url("themes/' + param.theme + '/images/gallery-scroll.png") 0px -35px no-repeat'
						});
					},
					mousedown: function(){
						$(this).css({
							'border': '1px solid rgb(247,199,64)',
							'background':'url("themes/' + param.theme + '/images/gallery-scroll.png") 0px -91px no-repeat'
						});
					},
					mouseup: function(){
						$(this).css({
							'border': '1px solid rgb(140,142,145)',
							'background': 'url("themes/' + param.theme + '/images/gallery-scroll.png") 0px -35px no-repeat'
						});
					}
				});
				$('.itemFilePage').live({
					mouseover: function(){
						itemType = $(this).attr("itemType");
						if (itemType=='button'){
							$(this).css({
								'background':'rgb(108,108,108) url("themes/' + param.theme + 
								'/images/item-file.png") 0 0 repeat',
								'border':'1px solid rgb(73,145,245)'
							});
						} else if (itemType=='popup'){
							if (blnLockFile==0){
								$(this).css({
									'background':'rgb(108,108,108) url("themes/' + param.theme + 
									'/images/item-file.png") 0 0 repeat',
									'border':'1px solid rgb(73,145,245)',
									'border-left':'1px solid transparent',
									'border-right':'1px solid transparent'
								});
							} else {
								itemID = $(this).attr("itemID");
								if (selItem == itemID){
									$(this).css({
										'background':'url("themes/' + param.theme + 
										'/images/left-popup.png") 0 0 no-repeat',
										'border':'1px solid transparent'
									});
								} else {
									$(this).css({
										'background':'rgb(108,108,108) url("themes/' + param.theme + 
										'/images/item-file.png") 0 0 repeat',
										'border':'1px solid rgb(73,145,245)',
										'border-left':'1px solid transparent',
										'border-right':'1px solid transparent'
									});
								}
							}
						}
					},
					mouseout: function(){
						itemType = $(this).attr("itemType");
						if (itemType=='button'){
							$(this).css({
								'background':'transparent',
								'border':'1px solid transparent'
							});
						} else  if (itemType=='popup'){
							if (blnLockFile==0){
								$(this).css({
									'background':'transparent',
									'border':'1px solid transparent'
								});
							} else {
								itemID = $(this).attr("itemID");
								if (selItem == itemID){
									$(this).css({
										'background':'url("themes/' + param.theme + 
										'/images/left-popup.png") 0 0 no-repeat',
										'border':'1px solid transparent'
									});
								} else {
									$(this).css({
										'background':'transparent',
										'border':'1px solid transparent'
									});
								}
							}
						}
					},
					mousedown: function(){
						itemType = $(this).attr("itemType");
						if (itemType=='button'){
							
						} else  if (itemType=='popup'){ 
							itemID = $(this).attr("itemID");
							$(".itemFilePage").css({
								'background':'transparent',
								'border':'1px solid transparent'
							});
							$(this).css({
								'background':'url("themes/' + param.theme + '/images/left-popup.png") 0 0 no-repeat',
								'border':'1px solid transparent'
							});
							blnLockFile=1;
							selItem = itemID; 
						}
					},
					click: function(){
						ribbon.onClick(this);
						ribbon.resizeForm();
					}
				});
				$('#messageBarClose').live({
					click: function(){
						ribbon.hideMsgBar();
					}
				});
				$('input').live({
					change: function(){
						param.onChange(this);
						var itemName = $(this).attr("itemName");
						var newVal = $(this).val();
						
						$('input').each(function(){
							var itemNames = $(this).attr("itemName");
							if (itemNames == itemName) {
								$(this).val(newVal);
							}
						});
					},
					keypress: function(event){
						param.onKeypress(this, event);
					},
					keydown: function(event){
						param.onKeydown(this, event);
					},
					keyup: function(event){
						param.onKeyup(this, event);
					}
				});
				$(window).resize(function(){ 
					ribbon.resizeForm(); 
				});
				$(document).ready(function(){
					ribbon.resizeForm();
				});
			},
			selectRibbonTab: function(id){
				//Clear selected tab
				$('.ribbonTab-left-tab').removeClass("ribbonTab-left-select");
				$('.ribbonTab-center-tab').removeClass("ribbonTab-center-select");
				$('.ribbonTab-right-tab').removeClass("ribbonTab-right-select");
				
				$('.ribbonTab-left-tab').removeClass("ribbonTab-left-hover");
				$('.ribbonTab-center-tab').removeClass("ribbonTab-center-hover");
				$('.ribbonTab-right-tab').removeClass("ribbonTab-right-hover");
				
				//Select new tab
				$('#ribbonTab-left-tab-' + id).addClass("ribbonTab-left-select");
				$('#ribbonTab-center-tab-' + id).addClass("ribbonTab-center-select");
				$('#ribbonTab-right-tab-' + id).addClass("ribbonTab-right-select");
				
				//Hide File page
				$('#filePage').hide();
				
				//Show ribbon & main form
				$('#mainFormContainer').show();
				$('#ribbonContainer').fadeIn('slow');
				
				//Hide all ribbon page
				$('.ribbonPage').hide();
					
				if (blnMinimized==1){
					$('#ribbonFrame-minimized').css('display', 'block');
					$('#ribbonPage-' + 'Min' + '-' + id, '#ribbonFrame-minimized').fadeIn('slow');
				} else {
					$('#ribbonPage-' + 'Max' + '-' + id, '#ribbonFrame-expand').fadeIn('slow');
				}
				
				selTab = id;
				blnShowFile = 0;
			},
			selectFileTab: function(){
				if (blnShowFile==0){
					tmpTab = selTab;
					$('#filePage').show();
					$('#mainFormContainer').hide();
					$('#ribbonContainer').hide();
					
					//Clear selected tab
					$('.ribbonTab-left-tab').removeClass("ribbonTab-left-select");
					$('.ribbonTab-center-tab').removeClass("ribbonTab-center-select");
					$('.ribbonTab-right-tab').removeClass("ribbonTab-right-select");
							
					$('.ribbonTab-left-tab').removeClass("ribbonTab-left-hover");
					$('.ribbonTab-center-tab').removeClass("ribbonTab-center-hover");
					$('.ribbonTab-right-tab').removeClass("ribbonTab-right-hover");
					
					$('#messageBarContainer').hide();
					
					blnShowFile = 1;
					selTab = 0;
				} else {
					if (tmpTab==0){
						
					} else {
						ribbon.selectRibbonTab(tmpTab);
						blnShowFile = 0;
						ribbon.resizeForm();
					}
				}
			},
			showPopup: function(id){
				var itemType = $("#"+id).attr("itemType");
				var itemID = $("#"+id).attr("itemID");
				
				var prefix = id.substring(0,3);
				
				if (itemType=="combo"){
					pos = $('#ribbonCombo-'+id).position();
					height = $('#ribbonCombo-'+id).height();
					
					posleft = pos.left;
					postop = pos.top;
					newtop = postop + height + 2;
				
					if (prefix=="Min"){
						newtop += 50;
					}
				} else {
					pos = $('#'+id).position();
					height = $('#'+id).height();
					
					posleft = pos.left;
					postop = pos.top;
					newtop = postop + height + 2;
				
					if (prefix=="Min"){
						newtop += 24;
					}
				}
				
				$("#menuContainer-" + id).css({
					'left': posleft + 'px',
					'top': newtop  + 'px'
				});
				$("#menuContainer-" + id).fadeIn('slow');
			},
			hidePopup: function(id){
				var itemType = $("#"+selItem).attr("itemType");
				var itemID = $("#"+selItem).attr("itemID");
				if (itemType=="combo"){
					$("#comboDropdown-"+itemID).css({
						'background':'url("themes/' + param.theme + '/images/combo.png") 0px 0px no-repeat'
					});
				} else {
					ribbon.smallItemOut("#"+id);
					ribbon.smallItemDropdownOut("#itemDropdown-"+id);
					ribbon.largeItemOut("#"+id);
					ribbon.largeItemCaptionOut("#itemCaption-"+id);
					ribbon.largeItemImageOut("#itemImage-"+id);	
				}
				$("#menuContainer-" + id).fadeOut('slow');
				selItem="";
				blnLock = 0;
			},
			showToolTip: function(obj){
				var pos = $(obj).position();
				
				$("#tooltip-"+id).css('left',pos.left +'px');
				//if ($('.popup-menu').css("display")=='none'){
					//if ($("#tooltip").css('display')=="none"){
						$("#tooltip"+id).fadeIn('slow');
					//} else {
						//$("#tooltip").css('display','block');
					//}
				//}
			},
			msgBar: function(title, text){
				$('#messageBarContainer').fadeIn();
				$('#messageBarText').html("<b>"+title+" :</b>" + "&nbsp;" + text);
				setTimeout("hideMsgBar()",5000);
			},
			hideMsgBar: function(){
				$('#messageBarContainer').hide();
				ribbon.resizeForm();
			},
			grayScale: function(img){
				var canvas = document.createElement('canvas');
				var ctx = canvas.getContext('2d');
					
				var imgObj = new Image();
				imgObj.src = img;
				   
				canvas.width = imgObj.width;
				canvas.height = imgObj.height; 

				ctx.drawImage(imgObj, 0, 0); 
			  
				var imgPixels = ctx.getImageData(0, 0, canvas.width, canvas.height);
					
				for(var y = 0; y < imgPixels.height; y++){
						for(var x = 0; x < imgPixels.width; x++){
						   var i = (y * 4) * imgPixels.width + x * 4;
						   var avg = (imgPixels.data[i] + 
									  imgPixels.data[i + 1] + 
									  imgPixels.data[i + 2]
									  ) / 3;
						   imgPixels.data[i] = avg; 
						   imgPixels.data[i + 1] = avg; 
						   imgPixels.data[i + 2] = avg;
						}
				}
				ctx.putImageData(imgPixels, 0, 0, 0, 0, imgPixels.width, imgPixels.height);
				return canvas.toDataURL();
			},
			makeGrayscale: function(){
				$('.imgItem').each(function(){
					itemEnabled = $(this).attr("itemEnabled");
					if (itemEnabled==0){
						this.src = ribbon.grayScale(this.src);
					}
				});
			},
			switchQuickbar: function(){
				
				switch (qbPosition){
				case "below":
					$("#quickbar1").hide();
					$("#quickbar2").show();
					qbPosition = "above"
				break;
				case "above":
					$("#quickbar1").show();
					$("#quickbar2").hide();
					qbPosition = "below"
				break;
				}
			},
			getHistory: function(){
				var id = $(obj).attr("id");
				strContent = $("#"+id).html();
				return strContent;
			},
			onClick: function(obj){
				itemForm = $(obj).attr('itemForm');
				itemAction = $(obj).attr('itemAction');
				
				if (itemForm==undefined){itemForm=''}
				if (itemForm=='undefined'){itemForm=''}
				
				if (itemAction==undefined){itemAction=''}
				if (itemAction=='undefined'){itemAction=''}
				
				if (itemForm == ''){
					if (itemAction == ''){
						if (param.onClick){
							param.onClick(obj);
						}
					} else {
						switch (itemAction){
						case "switchQuickbar":
							ribbon.switchQuickbar();
						break;
						case "close":
							ribbon.removeForm($('#'+selForm));
							ribbon.resizeForm();
						break;
						}
					}
				} else {
					ribbon.showForm(itemForm);
				}
			}
		};
		
		if (param.ribbonTabs){
			var ribbonTabs = param.ribbonTabs;
			
			var arrSmall = new Array();
			
			for (var i = 0; i < ribbonTabs.length; i++){
				tabCaption = ribbonTabs[i].caption;
				tabID = ribbonTabs[i].id;
				ribbon.createRibbonTab("ribbonTab", tabID, tabCaption);
				
				ribbon.createRibbonPage("ribbonFrame-minimized", "Min", tabID, tabCaption);
				ribbon.createRibbonPage("ribbonFrame-expand", "Max", tabID, tabCaption);
				
				ribbonGroups = ribbonTabs[i].ribbonGroups;
				
				if (ribbonGroups != undefined){
					if (ribbonGroups != 'undefined'){
						for (var j = 0; j < ribbonGroups.length; j++){
							
							groupID = ribbonGroups[j].id;
							groupCaption  = ribbonGroups[j].caption;
							
							ribbonOption = ribbonGroups[j].optionButton;
							
							ribbon.createRibbonGroup("ribbonGroupContainer-" + "Min" + "-" + tabID, "Min", groupID, groupCaption, ribbonOption);
							ribbon.createRibbonGroup("ribbonGroupContainer-" + "Max" + "-" + tabID, "Max", groupID, groupCaption, ribbonOption);
							
							ribbonItems = ribbonGroups[j].items;
							
							if (ribbonItems != undefined){
								if (ribbonItems != 'undefined'){
									var tempSize = "";
									var containerCount = 0;
									var smallCount = 0;
									var modSmall = 0;
									
									//Create container itema
									for (var k = 0; k < ribbonItems.length; k++){
										var itemID = ribbonItems[k].id;
										var itemSize = ribbonItems[k].size;
										var itemGrouped = ribbonItems[k].grouped;
										
										if (itemSize == 'large'){
											containerCount += 1;
											ribbon.createItemsContainer("GroupitemContainer-" + "Min" + "-" + groupID, "Min", itemID);
											ribbon.createItemsContainer("GroupitemContainer-" + "Max" + "-"  + groupID, "Max", itemID);
										} else if (itemSize == 'small'){
											if (tempSize == 'small'){
												smallCount += 1;
											} else {
												smallCount = 0;
												containerCount += 1;
												arrSmall[containerCount] = "";
												ribbon.createItemsContainer("GroupitemContainer-" + "Min" + "-" + 
												groupID, "Min", groupID + containerCount);
												ribbon.createItemsContainer("GroupitemContainer-" + "Max" + "-"  + 
												groupID, "Max", groupID + containerCount);
											}
											
											if (smallCount >= 3){
												if (itemGrouped==1) {
												
												} else {
													containerCount += 1;
													smallCount = 0;
													arrSmall[containerCount] = "";
													ribbon.createItemsContainer("GroupitemContainer-" + "Min" + "-" + 
													groupID, "Min", groupID + containerCount);
													ribbon.createItemsContainer("GroupitemContainer-" + "Max" + "-"  + 
													groupID, "Max", groupID + containerCount);
												}
											}
											
											arrSmall[containerCount] += itemID + ";" ; 
											
										}
										tempSize = itemSize
									}
									
									
									//Create container for small items
									
									for (var l = 1; l < containerCount+1; l++){
										if (arrSmall[l]) {
											var itemGroups = arrSmall[l].split(";");
											var itemGroup = itemGroups[0];
											ribbon.createSmallItemsContainer("itemContainer-" + "Min" + "-" + groupID + l , "Min", arrSmall[l]);
											ribbon.createSmallItemsContainer("itemContainer-" + "Max" + "-" + groupID + l , "Max", arrSmall[l]);
										}
									}
									for (var k = 0; k < ribbonItems.length; k++){
										var itemID = ribbonItems[k].id;
										var itemName = ribbonItems[k].name;
										var itemType = ribbonItems[k].type;
										var itemSize = ribbonItems[k].size;
										var itemWidth = ribbonItems[k].width;
										var itemImage = ribbonItems[k].image;
										var itemCaption = ribbonItems[k].caption;
										var itemChecked = ribbonItems[k].checked;
										var itemEnabled = ribbonItems[k].enabled;
										var itemGrouped = ribbonItems[k].grouped;
										var itemForm = ribbonItems[k].form;
										var itemAction = ribbonItems[k].action;
										
										var itemPopups = ribbonItems[k].popups;
										
										ribbon.createItem("itemContainer-" + "Min" + "-" + itemID, "Min" + "-" + itemID, itemType, itemSize, itemWidth,
										itemName, itemImage, itemCaption, itemChecked, itemEnabled, itemGrouped, itemForm, itemAction,"");
										ribbon.createItem("itemContainer-" + "Max" + "-" + itemID, "Max" + "-" + itemID, itemType, itemSize, itemWidth,
										itemName, itemImage, itemCaption, itemChecked, itemEnabled, itemGrouped, itemForm, itemAction,"");
										
										if (itemGrouped != undefined){
											if (itemGrouped != 'undefined'){
												if (itemGrouped != ''){
													var parentID = $('#'+itemID).parent().attr('id');
													var itemContainerID = $('#'+itemID).parent().parent();
													var smallContainerID = $('#'+itemID).parent().parent().parent().attr('id');
													
													$('#'+parentID).css({
														'float':'left',
														'margin-top':'6px',
													});
													
													$('#'+parentID).parent().css({
														'width':'auto'
													});
													
													$('#'+smallContainerID).css({
														'float':'left',
														'height':'68px'
													});
													
													$(itemContainerID).css({
														'height':'66px'
													});
												}
											}
										}
										
										if (itemPopups){
											ribbon.createMenuContainer("Min-" + itemID);
											ribbon.createMenuContainer("Max-" + itemID);
											
											for (var p = 0; p < itemPopups.length; p++){
												var popitemID = itemPopups[p].id;
												//alert(popitemID);
												var popitemName = itemPopups[p].name;
												var popitemType = itemPopups[p].type;
												var popitemSize = itemPopups[p].size;
												var popitemImage = itemPopups[p].image;
												var popitemCaption = itemPopups[p].caption;
												var popitemChecked = itemPopups[p].checked;
												var popitemEnabled = itemPopups[p].enabled;
												
												var popitemForm = itemPopups[p].form;
												var popitemAction = itemPopups[p].action;
												
												ribbon.createItemMenu('menuContainer-Min-' + itemID, "Min" + "-" + popitemID, 
												popitemType, popitemSize, popitemName, popitemImage, popitemCaption, 
												popitemChecked, popitemEnabled, popitemForm, popitemAction);
												
												ribbon.createItemMenu('menuContainer-Max-' + itemID, "Max" + "-" + popitemID, 
												popitemType, popitemSize, popitemName, popitemImage, popitemCaption, 
												popitemChecked, popitemEnabled, popitemForm, popitemAction);
												
											}
										}
									}
								}
							}
							
							var gallery = ribbonGroups[j].gallery;
							
							if (gallery){
								
								var galleryID = gallery[0].id;
								var galleryName = gallery[0].name;
								var galleryCaption = gallery[0].caption;
								var galleryLine = gallery[0].line;
								var galleryWidth = gallery[0].width;
								var galleryHeight = gallery[0].height;
								
								var itemGallery = gallery[0].items;
								
								
								ribbon.createItemsContainer("GroupitemContainer-" + "Min" + "-" + groupID, "Min", galleryID);
								ribbon.createItemsContainer("GroupitemContainer-" + "Max" + "-"  + groupID, "Max", galleryID);
								
								ribbon.createGalleryContainer(galleryLine, "itemContainer-" + "Min" + "-" + galleryID, "Min", galleryID, galleryName, galleryCaption, galleryWidth, galleryHeight);
								
								ribbon.createGalleryContainer(galleryLine, "itemContainer-" + "Max" + "-" + galleryID, "Max", galleryID, galleryName, galleryCaption, galleryWidth, galleryHeight );
								
								if (itemGallery){
									for (var p = 0; p < itemGallery.length; p++){
										var galleryItemID = itemGallery[p].id;
										var galleryItemName = itemGallery[p].name;
										var galleryItemType = itemGallery[p].type;
										var galleryItemSize = itemGallery[p].size;
										var galleryItemImage = itemGallery[p].image;
										var galleryItemCaption = itemGallery[p].caption;
										var galleryItemChecked = itemGallery[p].checked;
										var galleryItemEnabled = itemGallery[p].enabled;
										var galleryItemForm = itemGallery[p].form;
										var galleryItemAction = itemGallery[p].action;
										
										ribbon.createItemGallery(galleryLine, 'galleryItems-Min-' + galleryID, "Min" + "-" + galleryItemID, 
										galleryItemType, galleryItemSize, galleryItemName, galleryItemImage, 
										galleryItemCaption, galleryItemChecked, galleryItemEnabled, galleryItemForm, galleryItemAction);
										
										ribbon.createItemGallery(galleryLine, 'galleryItems-Max-' + galleryID, "Max" + "-" + galleryItemID, 
										galleryItemType, galleryItemSize, galleryItemName, galleryItemImage, 
										galleryItemCaption, galleryItemChecked, galleryItemEnabled, galleryItemForm, galleryItemAction);
										
									}
								}
								
							}
						}
									
						//	alert(containerCount);
					}
				}
			}
			
			ribbon.controlEvents();
			ribbon.makeGrayscale();
			
			if (param.tabIndex=='0'){
				ribbon.selectFileTab();
			} else {
				ribbon.selectRibbonTab(param.tabIndex);
			}
			
		}
		
		var qbPosition = "";
		
		if (param.quickBar){
			var quickBar = param.quickBar;
			var quickBarItems = quickBar.items;
			qbPosition = quickBar.position;
			
			if (quickBarItems){
				for (var p = 0; p < quickBarItems.length; p++){
					var qbitemID = quickBarItems[p].id;
					
					var qbitemName = quickBarItems[p].name;
					var qbitemType = quickBarItems[p].type;
					var qbitemSize = quickBarItems[p].size;
					var qbitemImage = quickBarItems[p].image;
					var qbitemCaption = quickBarItems[p].caption;
					var qbitemGrouped = quickBarItems[p].grouped;
					var qbitemChecked = quickBarItems[p].checked;
					var qbitemEnabled = quickBarItems[p].enabled;
					var qbitemWidth = quickBarItems[p].width;
					
					
					var qbitemForm = quickBarItems[p].form;
					var qbitemAction = quickBarItems[p].action;
					
					qbitemSize = "small";
					
					ribbon.createItem("quickbarBelow", "Below" + "-" + qbitemID, qbitemType, qbitemSize, qbitemWidth, qbitemName, qbitemImage, qbitemCaption, qbitemChecked, qbitemEnabled, qbitemGrouped, qbitemForm, qbitemAction, "li");
					
					ribbon.createItem("quickbarAbove", "Above" + "-" + qbitemID, qbitemType, qbitemSize, qbitemWidth, qbitemName, qbitemImage, qbitemCaption, qbitemChecked, qbitemEnabled, qbitemGrouped, qbitemForm, qbitemAction, "li");
				}
			}
		} else {
			qbPosition = 'above';
		}	
			
			if (param.icon){
				var strIcon = "<li style='padding:2px'>&nbsp;<img src='"+param.icon+"' style='width:16px;height:16px' />&nbsp;</li>";
				$("#quickbarBelow").prepend(strIcon);
				$("#quickbarAbove").prepend(strIcon);
			}
			
			var qbitemID = '99901';
			var qbitemName = 'quickPop';
			var qbitemType = 'buttonpopup';
			var qbitemSize = 'small';
			var qbitemImage = "contextdn.png";
			var qbitemCaption = "";
			var qbitemGrouped = "";
			var qbitemChecked = "";
			var qbitemWidth = "";
			
			switch (qbPosition){
			case 0, 'above':
				qbPosition = 'above';
				$("#quickbar2").hide();
			break;
			case 1, 'below':
				qbPosition = 'below';
				$("#quickbar1").hide();
			break;
			}
			
			ribbon.createItem("quickbarBelow", "Below" + "-" + qbitemID, qbitemType, qbitemSize, qbitemWidth, qbitemName, 
			qbitemImage, qbitemCaption, qbitemChecked, qbitemEnabled, qbitemGrouped, qbitemForm, qbitemAction, "li");
			
			ribbon.createItem("quickbarAbove", "Above" + "-" + qbitemID, qbitemType, qbitemSize, qbitemWidth, qbitemName, 
			qbitemImage, qbitemCaption, qbitemChecked, qbitemEnabled, qbitemGrouped, qbitemForm, qbitemAction, "li");
			
			ribbon.createMenuContainer("Above-" + qbitemID);
			ribbon.createItemMenu('menuContainer-Above-' + qbitemID, "Above" + "-" + '9990101', 
			'button', 'small', 'show', 'contextdn.png', 'Show below the ribbon', '', '1', '', 'switchQuickbar');
			
			ribbon.createMenuContainer("Below-" + qbitemID);
			ribbon.createItemMenu('menuContainer-Below-' + qbitemID, "Below" + "-" + '9990101', 
			'button', 'small', 'show', 'contextdn.png', 'Show above the ribbon', '', '1', '', 'switchQuickbar');
		
		if (param.statusBar){
			var statusBar = param.statusBar;
			var stbPanels = statusBar.panels;
			
			for (var p = 0; p < stbPanels.length; p++){
				var panelID = stbPanels[p].id;
				var panelName = stbPanels[p].name;
				var panelWidth = stbPanels[p].width;
				var panelAlign = stbPanels[p].align;
				
				ribbon.createPanel(panelID, panelName, panelAlign, panelWidth);
				
				var panelItems = stbPanels[p].items;
				if (panelItems){
					for (var k = 0; k < panelItems.length; k++){
						var itemID = panelItems[k].id;
						var itemName = panelItems[k].name;
						var itemType = panelItems[k].type;
						var itemSize = panelItems[k].size;
						var itemWidth = panelItems[k].width;
						var itemImage = panelItems[k].image;
						var itemCaption = panelItems[k].caption;
						var itemChecked = panelItems[k].checked;
						var itemEnabled = panelItems[k].enabled;
						var itemGrouped = panelItems[k].grouped;
						var itemForm = panelItems[k].form;
						var itemAction = panelItems[k].action;
						var itemSize = "small";
						
						ribbon.createItem("panelContent-" + panelID, itemID, itemType, itemSize, itemWidth, itemName, itemImage, itemCaption, itemChecked, itemEnabled, itemGrouped, itemForm, itemAction, "li");
					}
				}
			}
		}
		
		//Create Toolbar
		if (param.ribbonButtons){
			var ribbonButtons = param.ribbonButtons;
			var toolItems = ribbonButtons.items;
			for (var p = 0; p < toolItems.length; p++){
				var itemID = toolItems[p].id;
				var itemName = toolItems[p].name;
				var itemWidth = toolItems[p].width;
				var itemImage = toolItems[p].image;
				var itemType = toolItems[p].type;
				var itemCaption = toolItems[p].caption;
				var itemChecked = toolItems[p].checked;
				var itemEnabled = toolItems[p].enabled;
				var itemForm = toolItems[p].form;
				var itemAction = toolItems[p].action;
				var itemGrouped = "";
				var itemSize = "small";
				
				ribbon.createItem("ribbonButton", itemID, itemType, itemSize, itemWidth, itemName, itemImage, itemCaption, itemChecked, itemEnabled, itemGrouped, itemForm, itemAction, "li");
				
			}
		};
		
		if (param.filePage){
			var filePage = param.filePage;
			var fileItems = filePage.items;
			if (fileItems){
				for (var k = 0; k < fileItems.length; k++){
					var itemID = fileItems[k].id;
					var itemName = fileItems[k].name;
					var itemType = fileItems[k].type;
					var itemImage = fileItems[k].image;
					var itemCaption = fileItems[k].caption;
					var itemEnabled = fileItems[k].enabled;
					var itemForm = fileItems[k].form;
					var itemAction = fileItems[k].action;
					ribbon.createItemFile(itemID, itemType, itemName, itemImage, itemCaption, itemEnabled, itemForm, itemAction);
				}
			}
		}
		
		//Create Toolbar
		if (param.toolBar){
			var toolBar = param.toolBar;
			var toolItems = toolBar.items;
			for (var p = 0; p < toolItems.length; p++){
				var itemID = toolItems[p].id;
				var itemName = toolItems[p].name;
				var itemWidth = toolItems[p].width;
				var itemImage = toolItems[p].image;
				var itemType = toolItems[p].type;
				var itemCaption = toolItems[p].caption;
				var itemChecked = toolItems[p].checked;
				var itemEnabled = toolItems[p].enabled;
				var itemForm = toolItems[p].form;
				var itemAction = toolItems[p].action;
				var itemGrouped = "";
				var itemSize = "medium";
				ribbon.createItem("toolBar", itemID, itemType, itemSize, itemWidth, itemName, itemImage, itemCaption, itemChecked, itemEnabled, itemGrouped, itemForm, itemAction, "li");
			}
		};
		
		//Create Tooltip
		if (param.toolTip){
			var toolTip = param.toolTip;
			var toolItems = toolTip.items;
			for (var p = 0; p < toolItems.length; p++){
				var itemID = toolItems[p].id;
				var itemWidth = toolItems[p].width;
				var itemImage = toolItems[p].image;
				var itemType = toolItems[p].type;
				var itemTitle = toolItems[p].title;
				var itemContent = toolItems[p].content;
				
				ribbon.createToolTip(itemID, itemType, itemWidth, itemImage, itemTitle, itemContent);
			}
		};
		
		//Create FormLogo
		if (param.logo){
			var logo = param.logo;
			
			var htmlLogo = $.ajax({
				url: "forms/" + param.prefixForm + logo + "." + param.extForm,
				async: false
			}).responseText; 
			
			$("#formLogo").html(htmlLogo);
		};
		
		ribbon.hideMsgBar();
			
		if (param.onReady) {
			param.onReady();
		}
		obj.param = param;
		obj.ribbon = ribbon;
		return obj;
	};
	
	$.fn.inochiRibbon = function(options) {
		return this.each(function() {
			$.loadTheme(this, options);
			$.createRibbon(this, options);
		});
	};
	
})(jQuery);
